I've been programming for years now, but never had to do anything with encryption/decryption.
So I've got the following PHP:
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_,', '+/='));
}
function AESdecrypt($phrase, $user_key){
$key = pack('H*', $user_key);
$ciphertext_dec = base64_url_decode($phrase);
# may remove 00h valued characters from end of plain text
$plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key,
$ciphertext_dec, MCRYPT_MODE_ECB);
return $plaintext_dec;
}
echo AESdecrypt(
"-GZmiQhJYnzw0FXTR6QoLryPNlgcScbfgZnmzgA35tydozNwsKWdXvIEtqWjhJIGCYdVVKB0lBKUTx-TXxHnIQn680mZIZ8lG7HNTMgprxM,",
"2dd9bb29d2e25c18bdc12d7b75f6f5d0ef3d99ef310a0319e2796bb30278b24c557f78b6c958faa55d70ce081f2607a0e62b9fa01e2483f9a75b032b7fd9678c"
);
The output of this is
1kYJjUajo8bIlsT5CVCSqYglD_dQX-fjuIHkEFzfJouiI7Nx29IEtZ8QwTvIH6yx5uI,
I've created a JS fiddle to simulate what I have in javascript: http://jsfiddle.net/NdT3P/3/ (please scroll down to line 545 since I've pasted in some libraries I was using).
Relevant Javascript code:
var user_key = "2dd9bb29d2e25c18bdc12d7b75f6f5d0ef3d99ef310a0319e2796bb30278b24c557f78b6c958faa55d70ce081f2607a0e62b9fa01e2483f9a75b032b7fd9678c";
user_key = pack('H*', user_key);
console.log(user_key); // same as the php functions
var decrypted_wallet = "-GZmiQhJYnzw0FXTR6QoLryPNlgcScbfgZnmzgA35tydozNwsKWdXvIEtqWjhJIGCYdVVKB0lBKUTx-TXxHnIQn680mZIZ8lG7HNTMgprxM,"
decrypted_wallet = Base64.decode(strtr(decrypted_wallet, '-_,', '+/='));
console.log(decrypted_wallet); //same as the php function
var decrypted = CryptoJS.AES.decrypt(user_key,decrypted_wallet,{ mode: CryptoJS.mode.ECB });
console.log(decrypted.toString(CryptoJS.enc.Utf8)); // empty string
Anyone could point in the right direction?