Created
September 24, 2018 07:34
-
-
Save andrii-trush/01e1e8b4ff36edda5468ccc959b06987 to your computer and use it in GitHub Desktop.
CryptoJS + php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$key = hex2bin("A9392200EE003FA282FD26B6FE6E408F66E8FA57AE9B37A81AB1EA6D2CEB8591"); | |
$iv = hex2bin("0A8F11794D8CB7FD05F8C5A18B0B2AB6"); | |
$text = 'FJZXx9cIM40H981AfaZT2jfj+7vFhbx8h288Q589/Wc='; | |
$decrypted = openssl_decrypt($text, 'AES-256-CBC', $key, OPENSSL_ZERO_PADDING, $iv); | |
?> | |
<!doctype> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script> | |
</head> | |
<body> | |
<p></p> | |
<script> | |
var key = CryptoJS.enc.Hex.parse("A9392200EE003FA282FD26B6FE6E408F66E8FA57AE9B37A81AB1EA6D2CEB8591"); | |
var iv = CryptoJS.enc.Hex.parse("0A8F11794D8CB7FD05F8C5A18B0B2AB6"); | |
var text = CryptoJS.AES.encrypt(JSON.stringify({text: "Hello my dear friend"}), key, { | |
iv, | |
padding: CryptoJS.pad.ZeroPadding, | |
}).toString(); | |
document.querySelector('p').innerHTML = text; | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment