php、java、android、ios通用的3des方法
<?php
class DES3 {
var $key = "my.oschina.net/penngo?#@";
var $iv = "01234567";
function encrypt($input){
$size = mcrypt_get_block_size(MCRYPT_3DES,MCRYPT_MODE_CBC);
$input = $this->pkcs5_pad($input, $size);
$key = str_pad($this->key,24,'0');
$td = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_CBC, '');
if( $this->iv == '' )
{
$iv = @mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
}
else
{
$iv = $this->iv;
}
@mcrypt_generic_init($td, $key, $iv);
$data = mcrypt_generic($td, $in