php rsa类的一个写法
class des{ function encrypt($encrypt,$key) { $encrypt =Des::pkcs5_pad($encrypt); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_DES, MCRYPT_MODE_ECB), MCRYPT_RAND); $passcrypt = mcrypt_encrypt(MCRYPT_DES, $key, $encrypt, MCRYPT_MODE_ECB, $iv); return strtoupper(bin2hex($passcrypt)); } function decrypt($decrypt,$key) { $decoded = @pack("H*", $decrypt); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_DES, MCRYPT_MODE_ECB), MCRYPT_RAND); $decrypted = mcrypt_decrypt(MCRYPT_DES, $key, $decoded, MCRYPT_MODE_ECB, $iv); return Des::pkcs5_unpad($decrypted); } function pkcs5_unpad($text){ $pad = ord($text{strlen($text)-1}); if ($pad > strlen($text)) return $text; if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return $text; return substr($text, 0, -1 * $pad); } function pkcs5_pad($text){ $len = strlen($text); $mod = $len % 8; $pad = 8 - $mod; return $text.str_repeat(chr($pad),$pad); } }
还需要深入研究下,生成证书啥的
Meet so Meet.
C plusplus
I-PLUS....