crypto-js暗号化(DES)php mcrypt_decrypt復号
2738 ワード
function post(URL, PARAMS) //post
{
var temp = document.createElement("form");
temp.action = URL;
temp.method = "post";
temp.style.display = "none";
for (var x in PARAMS)
{
var opt = document.createElement("textarea");
opt.name = x;
opt.value = PARAMS[x];
// alert(opt.name)
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}
function encrypt(input, timestamp) { //
return CryptoJS.TripleDES.encrypt(input,CryptoJS.enc.Utf8.parse(timestamp), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
}
// 3des/ECB/PKCS7
function decrypt(input, timestamp) {
var decryptData = CryptoJS.TripleDES.decrypt(input, CryptoJS.enc.Utf8.parse(timestamp), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
//return decryptData.toString();
return decryptData.toString(CryptoJS.enc.Utf8);
// return JSON.parse(decryptData.toString(cryptoJS.enc.Utf8));
}
var datt="abcdefggeee"
//console.log(encrypt(datt,'789'));
//alert(encrypt(datt,'789'));
str=encrypt(datt,'789');
//alert(decrypt(str,'789'));
//console.log(decrypt(str,'789'));
//document.getElementById("usr").value=str;
function submitpos(){
post('new.php', {dat:str,username:'userID'});
}
";
echo " :".myDecrypt($str,"789");
}
?>