Tag:asc creat str Analysis target ati decode security decoding
<script type= "Text/javascript" src= "/cryptojs/aes.js" ></SCRIPT>
<script type= "text/ JavaScript "src="/cryptojs/pad-zeropadding.js "></SCRIPT>
<script type=" Text/javascript ";
var data= "test";//cryptographic string
var key = CryptoJS.enc.Latin1.parse (' @12345678912345! '); /Key
var IV = CryptoJS.enc.Latin1.parse (' @12345678912345! '); /keep consistent with key
//encryption
var data = json.stringify (data);//Convert the object to a JSON string
var encrypted = CryptoJS.AES.encrypt (data, Key,{iv:iv,mode:cryptojs.mode.cbc,padding:cryptojs.pad.zeropadding});
Encrypted=encodeuricomponent (encrypted);
document.write (decrypted);//Output encrypted string
//Decrypt
var data= "encrypted string";
Key and IV are consistent with the encryption
var decrypted = CryptoJS.AES.decrypt (data,key,{iv:iv,padding:cryptojs.pad.zeropadding});
Decrypted=decrypted.tostring (CryptoJS.enc.Utf8);
document.write (decrypted);//output decrypted data
</script>
Note: In the actual use of the time and PHP transmission, JS encrypted string inside the browser parsed into a blank space and then PHP decryption error; Here you can do further processing of the encrypted string encrypted=encodeuricomponent ( encrypted); That's not the problem.
PHP encryption and decryption method:
$privateKey = "@12345678912345!";
$iv = "@12345678912345!";
Encryption
$encrypted =mcrypt_encrypt (mcrypt_rijndael_128, $privateKey, $data, MCRYPT_MODE_CBC, $IV);
echo Base64_encode ($encrypted);
Decrypt
$encryptedData =base64_decode ($data);
$decrypted =mcrypt_decrypt (mcrypt_rijndael_128, $privateKey, $encryptedData, MCRYPT_MODE_CBC, $IV);
$decrypted =rtrim ($decrypted, "");//Note! Six red dots will appear behind the decrypted data, which can be processed without affecting further data manipulation
return $decrypted;
PS: About encryption and decryption of interested friends can also refer to the site online tools:
BASE64 Encoding and decoding tool:
Http://tools.jb51.net/transcoding/base64
Password Security online detection:
Http://tools.jb51.net/password/my_password_safe
High Strength Password Generator:
Http://tools.jb51.net/password/CreateStrongPassword
MD5 Online Encryption Tool:
Http://tools.jb51.net/password/CreateMD5Password
Online hashing/hashing algorithm encryption tool:
Http://tools.jb51.net/password/hash_encrypt
Online md5/hash/sha-1/sha-2/sha-256/sha-512/sha-3/ripemd-160 Encryption Tool:
Http://tools.jb51.net/password/hash_md5_sha
Online sha1/sha224/sha256/sha384/sha512 Encryption Tool:
Http://tools.jb51.net/password/sha_encode
JS implementation of AES encryption and interoperability with PHP method analysis