您的足迹:首页 > php知识 >php AES/ECB/PKCS5Padding加密

php AES/ECB/PKCS5Padding加密

AES/ECB/PKCS5Padding加密

iv;
        $encryptKey = $this->encryptKey;
        //Open module
        $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, $localIV);
        //print "module = $module 
" ; mcrypt_generic_init($module, $encryptKey, $localIV); //Padding $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $pad = $block - (strlen($encryptStr) % $block); //Compute how many characters need to pad $encryptStr .= str_repeat(chr($pad), $pad); // After pad, the str length must be equal to block or its integer multiples //encrypt $encrypted = mcrypt_generic($module, $encryptStr); //Close mcrypt_generic_deinit($module); mcrypt_module_close($module); return strtoupper(bin2hex($encrypted)); } } $parm = 'code_id=a10001&os_ver=5.1.1&app_ver=7.0&imei=867068020992938&mac=9C:99:A0:FF:E9:15&android_id=eedbdb39f66910a4&sw=1440&sh=2560&ot=1&ct=100'; $encrypt_obj = new encrypt_parm(); $encrypt_result = $encrypt_obj->encrypt($parm);//加密结果 $url = 'http://test.hahasdaq.com/v/v.do?p='; $regurl = $url.$encrypt_result; print $regurl."\n"; //result: //http://test.hahasdaq.com/v/v.do?p=4BFC51833EC459F5B87A07D22EBB8145DD207947F3EF624AE35AA577069790360C8FCBFB9D46B1BB8569772C075E25EAE152502DA1B97ECE909DC42B41FD49933398E4804D66DCDAF31963125FA3B81A36C60F0000E6500C246F031805EF72B899F5D9A2E28FBA51AE101C9D7D61A3A60BEFC0830F9985B4E51F64137ACBFD130139B12F654A4478DC6208F77DE3C5AE ?>


相关推荐

网友评论(0)