Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no value returned.. #22

Closed
swissonelabs opened this issue May 18, 2020 · 3 comments
Closed

no value returned.. #22

swissonelabs opened this issue May 18, 2020 · 3 comments

Comments

@swissonelabs
Copy link

swissonelabs commented May 18, 2020

I am pretty much copying your example - in php

$encrypted_mm = Helper::cryptoJsAesEncrypt('foobar', '123456');
echo $encrypted_mm ;
//which gives me this //{"ct":"pi6z3m0q4jscZKuhXobHoQ==","iv":"6311ee9d122636ac3bf9a0a9abc4b370","s":"f0f067ba05bdb331"}

then in js

let encrypted = '{"ct":"pi6z3m0q4jscZKuhXobHoQ==","iv":"6311ee9d122636ac3bf9a0a9abc4b370","s":"f0f067ba05bdb331"}'
        let password = '123456'
        let decrypted = CryptoJS.AES.decrypt(encrypted, password, { format: CryptoJSAesJson }).toString(CryptoJS.enc.Utf8)
        console.log('Decrypted: ' + decrypted)

// it is empty..but when I use your foobar encrypted values it works...any idea...fighting for 3 straight hours..

@brainfoolong
Copy link
Owner

Hi. Without seeing what Helper::cryptoJsAesEncrypt does, i cannot know what the issue is. Decrypting part looks fine.

@swissonelabs
Copy link
Author

wow! there is the issue..I copied your code from Stackoverflow and it has passphrase as the first param.
Thanks so much

@brainfoolong
Copy link
Owner

Alright, the code from Github is old and doesn't work with the new examples here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant