$digit) { $sum += $digit * $weights[$i % count($weights)]; } $checkDigit = (10 - ($sum % 10)) % 10; return $checkDigit; } // 初期パスワード作成 public static function createPassword() { // 使用可能文字 (使用不可:1,l,L,i,I,z,Z,2,o,O,0) $chars = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz3456789'; $password = ''; $length = 8; $max = strlen($chars) - 1; for ($i = 0; $i < $length; $i++) { $password .= $chars[random_int(0, $max)]; } return $password; } // パスワードハッシュ化 public static function hashPassword($user_seq, $password) { $hash = hash('sha256', $password) . $user_seq . 'SOMSALT'; for ($i = 0; $i < 25; $i++) { $hash = hash('sha256', $hash); } return $hash; } // パスワード照合 public static function verifyPassword($user_seq, $inputPassword, $hashedPassword) { return self::hashPassword($user_seq, $inputPassword) === $hashedPassword; } }