/** * @param $password * * @return string * @throws PasswordConstraintsException */ public function encrypt($password) { if (PasswordConstraintsService::singleton()->validate($password)) { $salt = helpers_Random::generateString($this->saltLength); return $salt . hash($this->algorithm, $salt . $password); } throw new PasswordConstraintsException(__('Password must be: %s', implode(',', PasswordConstraintsService::singleton()->getErrors()))); }
public function testCreateIndex() { $tokenizer = new core_kernel_classes_Resource(RawValue::URI); $id = 'test_index_' . helpers_Random::generateString(8); $index = IndexService::createIndex($this->property, $id, $tokenizer, true, true); $this->assertIsA($index, 'oat\\tao\\model\\search\\Index'); $this->assertTrue($index->exists()); $indexToo = IndexService::getIndexById($id); $this->assertIsA($indexToo, 'oat\\tao\\model\\search\\Index'); $this->assertTrue($index->equals($indexToo)); $this->assertEquals($id, $index->getIdentifier()); $this->assertTrue($index->isDefaultSearchable()); $this->assertTrue($index->isFuzzyMatching()); $tokenizer = $index->getTokenizer(); $this->assertIsA($tokenizer, 'oat\\tao\\model\\search\\tokenizer\\Tokenizer'); $indexes = IndexService::getIndexes($this->property); $this->assertTrue(is_array($indexes)); $this->assertEquals(1, count($indexes)); $indexToo = reset($indexes); $this->assertIsA($indexToo, 'oat\\tao\\model\\search\\Index'); $this->assertTrue($index->equals($indexToo)); return $index; }
/** * Generate an alphanum token to be used as a PHP session name. * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @return string */ public static function generateSessionName() { return 'tao_' . helpers_Random::generateString(8); }
public function encrypt($password) { $salt = helpers_Random::generateString($this->saltLength); return $salt . hash($this->algorithm, $salt . $password); }