[SECURITY] Better token generator

This commit is contained in:
Sebastian Grewe 2013-12-30 12:15:36 +01:00
parent fad153728a
commit 2c18abf8be

View File

@ -29,11 +29,11 @@ class Token Extends Base {
* @return mixed Token string on success, false on failure
**/
public function createToken($strType, $account_id=NULL) {
$strToken = hash('sha256', $account_id.$strType.microtime());
if (!$iToken_id = $this->tokentype->getTypeId($strType)) {
$this->setErrorMessage('Invalid token type: ' . $strType);
return false;
}
$strToken = bin2hex(openssl_random_pseudo_bytes(32));
$stmt = $this->mysqli->prepare("
INSERT INTO $this->table (token, type, account_id)
VALUES (?, ?, ?)