GoEasy-OTP > PHP生成GoEasy-OTP
 

GoEasy-OTP - PHP生成GoEasy-OTP

PHP

    public function goEasyOTP($secretKey){
        $key = $secretKey;
        //$key=86726e4356dce2d3;
        list($t1, $t2) = explode(' ', microtime());
        $text=(float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
        $text = "000".$text;
        //$text = "0001490325990593";
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $crypttext =base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_ECB, $iv));
        return $crypttext;
    }

验证OTP生成结果

测试参数:

secret key:86726e4356dce2d3

系统毫秒数:0001490325990593

测试结果:

GoEasy-otp:+rOKqbTZioistsdMrhon0A==

相关链接:

什么是GoEasy-OTP?
如何使用GoEasy-OTP?
验证GoEasy-OTP生成结果
Java生成GoEasy-OTP
PHP生成GoEasy-OTP
Python生成GoEasy-OTP
Ruby生成GoEasy-OTP
C#生成GoEasy-OTP

results matching ""

    No results matching ""