<body>
<script>
Account_encrypt (" 123 ");
The function account_encrypt (account) {
Alert (' CryptoJS='+ CryptoJS);
Alert (' CryptoJS. AES='+ CryptoJS. AES);
Alert (' CryptoJS. MD5='+ CryptoJS. MD5);
}
Var CryptoJS=the require (" crypto - js ");
</script>
<body/& gt;
CodePudding user response:
<body>
<script>
The function account_encrypt (" 123 ");
The function account_encrypt (account) {
Alert (' CryptoJS='+ CryptoJS);
Alert (' CryptoJS. AES='+ CryptoJS. AES);
Alert (' CryptoJS. MD5='+ CryptoJS. MD5);
}
Var CryptoJS=the require (" crypto - js ");
</script>
<body/& gt;
CodePudding user response:
<body>Click & lt;/button>
<script>
The function account_encrypt (account) {
Alert (' CryptoJS='+ CryptoJS);
Alert (' CryptoJS. AES='+ CryptoJS. AES);
Alert (' CryptoJS. MD5='+ CryptoJS. MD5);
}
Var CryptoJS=the require (" crypto - js ");
</script>
<body/& gt;
CodePudding user response:
<script SRC="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js" & gt; </script>
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Const key=CryptoJS. Enc. Utf8. Parse (" Gq, JPN97y hbtZ! # E + zh6AKQ4ts & gt; 8 b4a ");//16 hexadecimal number as key
Const iv=CryptoJS. Enc. Utf8. Parse (' Gq, JPN97y hbtZ! # ');//16 hexadecimal number as key offset
//decryption method
The function Decrypt (word) {
The word=btoa (word)
Let the decrypt=CryptoJS. AES. The decrypt (key word, {
Iv: iv.
Mode: CryptoJS. Mode. CBC,
Padding: CryptoJS. Pad. Pkcs7
});
Let decryptedStr=decrypt. ToString (CryptoJS. Enc. Utf8);
Return decryptedStr. ToString ();
}
//encryption method
The function Encrypt (word) {
Let SRCS=CryptoJS. Enc. Utf8. Parse (word);
Let encrypted=CryptoJS. AES. Encrypt (SRCS, key, {
Iv: iv.
Mode: CryptoJS. Mode. CBC,
Padding: CryptoJS. Pad. Pkcs7
});
Return encrypted. The toString ();
}
The console. The log (Decrypt (' L6FlPJrR0UaJOv0IClMjPQ==))
The console. The log (Encrypt (' a '))
Let the STR=atob (Encrypt (' - tests - '))