When doing docking, the service provider AES encryption through the SHA1PRNG algorithm (as long as the password, each generation of the array is the same, so can be used to do encryption and decryption key) for another time encryption, engaged for several hours, directly see the corresponding code bar, you can refer to, Java-only encrypted source
Private Static byte[] Encrypt (byte[] bytecontent,byte[] password)throwsException {keygenerator KGen= Keygenerator.getinstance ("AES"); SecureRandom SecureRandom= Securerandom.getinstance ("Sha1prng"); Securerandom.setseed (password); Kgen.init (128, SecureRandom); Secretkey Secretkey=Kgen.generatekey (); byte[] Encodeformat =secretkey.getencoded (); Secretkeyspec Key=NewSecretkeyspec (Encodeformat, "AES"); Cipher Cipher= Cipher.getinstance ("AES"); Cipher.init (1, key); byte[] result =cipher.dofinal (bytecontent); returnresult; }
Private Function _pkcs5pad ($text, $blockSize) {$pad = $blockSize-(strlen ($text)% $blockSize); Return $text. Str_repeat (Chr ($pad), $pad); } Private Function _pkcs5unpad ($text) {$end = substr ($text,-1); $last = Ord ($end); $len = strlen ($text)-$last; if (substr ($text, $len) = = Str_repeat ($end, $last)) {return substr ($text, 0, $len); } return false; The Public function encrypt ($encrypt, $key) {$blockSize = Mcrypt_get_block_size (mcrypt_rijndael_128, Mcrypt_mo DE_ECB); $paddedData = $this->_pkcs5pad ($encrypt, $blockSize); $ivSize = Mcrypt_get_iv_size (mcrypt_rijndael_128, MCRYPT_MODE_ECB); $iv = Mcrypt_create_iv ($ivSize, Mcrypt_rand); $key 2 = substr (Openssl_digest (Openssl_digest ($key, ' SHA1 ', true), ' SHA1 ', true), 0, 16); $encrypted = Mcrypt_encrypt (mcrypt_rijndael_128, $key 2, $paddedData, MCRYPT_MODE_ECB, $IV); Return Base64_encode ($encrypted); The public function decrypt ($decrypt, $key) {$decoded = $this->hex2bin ($decrypt); $blockSize = Mcrypt_get_iv_size (mcrypt_rijndael_128, MCRYPT_MODE_ECB); $iv = Mcrypt_create_iv ($blockSize, Mcrypt_rand); $decrypted = Mcrypt_decrypt (mcrypt_rijndael_128, $key, $decoded, MCRYPT_MODE_ECB, $IV); return $this->_pkcs5unpad ($decrypted); } function Hex2bin ($str) {$sbin = ""; $len = strlen ($STR); for ($i = 0; $i < $len; $i + = 2) {$sbin. = Pack ("h*", substr ($str, $i, 2)); } return $sbin; }
PHP AES encryption corresponds to Java sha1prng mode encryption