Christ260 / crypto-js

Automatically exported from code.google.com/p/crypto-js
0 stars 0 forks source link

Error decrypting an AES encrypted text #108

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

I have the following function:

    decryptBody: function(body) {
        console.log(body);
        var key = Meteor.settings.encryptionKey;
        console.log(key);
        decrypted = CryptoJS.AES.decrypt(body, key);
        var decryptedBody = decrypted.toString(CryptoJS.enc.Utf8);
        console.log(decryptedBody);
        return decryptedBody;
    }

The error is the following (of course body is a string with a value):

I2048-22:51:59.933(1)? Exception while invoking method 'decryptBody' TypeError: 
Cannot call method 'parse' of undefined
I2048-22:51:59.933(1)?     at Object.CryptoJS.lib.Cipher.C_format.OpenSSL.parse 
(packages/crypto-aes/cipher-core.js:605)
I2048-22:51:59.933(1)?     at 
Object.CryptoJS.lib.Cipher.C_lib.SerializableCipher.Base.extend._parse 
(packages/crypto-aes/cipher-core.js:726)
I2048-22:51:59.933(1)?     at 
Object.CryptoJS.lib.Cipher.C_lib.PasswordBasedCipher.SerializableCipher.extend.d
ecrypt (packages/crypto-aes/cipher-core.js:849)
I2048-22:51:59.934(1)?     at Object.decrypt 
(packages/crypto-aes/cipher-core.js:196)
I2048-22:51:59.934(1)?     at Meteor.methods.decryptBody 
(app/server/messages.js:30:34)
I2048-22:51:59.934(1)?     at maybeAuditArgumentChecks 
(packages/livedata/livedata_server.js:1356)
I2048-22:51:59.934(1)?     at packages/livedata/livedata_server.js:541
I2048-22:51:59.934(1)?     at _.extend.withValue 
(packages/meteor/dynamics_nodejs.js:35)
I2048-22:51:59.935(1)?     at packages/livedata/livedata_server.js:540
I2048-22:51:59.935(1)?     at _.extend.withValue 
(packages/meteor/dynamics_nodejs.js:35)

Original issue reported on code.google.com by santine...@gmail.com on 24 Nov 2013 at 9:57

GoogleCodeExporter commented 8 years ago
You need to provide more information to reproduce the issue. What's the value 
of the body? What's the value of the key?

Original comment by Jeff.Mott.OR on 24 Nov 2013 at 10:49

GoogleCodeExporter commented 8 years ago
body contains an utf8 string and key is the passphrase.

I played a bit with the wrapper for Meteor and it looks like Base64 isn't 
defined. It's probably a missing dependency.

Valerio Santinelli

Inviato da iPhone

Original comment by santine...@gmail.com on 25 Nov 2013 at 7:27

GoogleCodeExporter commented 8 years ago
> body contains an utf8 string and key is the passphrase.

That doesn't help to reproduce the issue.

Original comment by Jeff.Mott.OR on 26 Nov 2013 at 7:03

GoogleCodeExporter commented 8 years ago
You can close this issue as it was related to the Meteor wrapper missing
the Base64 dependency. Thanks.

Original comment by santine...@gmail.com on 26 Nov 2013 at 7:30

GoogleCodeExporter commented 8 years ago

Original comment by Jeff.Mott.OR on 26 Nov 2013 at 9:29