Created
August 21, 2015 07:18
-
-
Save 42milez/59033305d8968d884435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Aug. 21, 2015 - Akihiro TAKASE | |
* | |
* 本ファイルにはハッシュを扱うユーティリティクラスの定義が含まれます。 | |
* | |
*/ | |
class Util_Hash { | |
// ストレッチング回数 | |
const ITERATION_COUNT = 10000; | |
// ソルト生成関数(16進数表現) | |
public static function getSalt() { | |
// パフォーマンスを優先し、ノンブロッキングな擬似乱数発生器を使用する | |
return bin2hex(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)); | |
} | |
// ハッシュ化パスワード生成関数(16進数表現) | |
public static function getHashedPassword($password, $salt) { | |
return hash_pbkdf2('sha256', $password, $salt, self::ITERATION_COUNT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment