-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Question about MySQL AES_ENCRYPT -> Node.js AES decipher BUFFER #419
Comments
Why don't you use mysql to do the oposite? connection.query("SELECT AES_DECRYPT(password, 'password') AS password FROM Accounts", ...); |
If you think your decoding is right, you can also just convert the Buffer to string using |
@dresende I don't know how to decipher the returned <Buffer 07 86... value or openssl doesnt support the correct needed AES decryption for MySQL AES encryption (meanwhile i believe this..,) |
If you're worried that your AES_DECRYPT query will show up in logs or will be visible by any man-in-the-middle, you should also worry about AES_ENCRYPT (when you send it in the first place). If that's your concern, you should just avoid encryption stuff on the database and just do it (encrypt/decrypt) in nodejs. About http://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end |
@dresende Yep, i know the Node.JS Buffer module, i believe i failed because MySQL using a different AES-128-ECB algorithm, which I cannot realize so easily with Node.Js crypto module like i hoped. Thank you for trying to help :) |
As I already quoted on stackoverflow - here again because it might be useful for other people: Your passwords must be converted the same way MySQL will do it internally.
MySQL-compatible encryption - note to use "createCipheriv" with an empty IV. (createCipher creates an own IV which is not the same as in MySQL)
Which is the same like:
Decryption
|
Thanks to @dbogatz , I create a tiny npm module based on code presents here. |
DSN: Add cfg.FormatDSN method
Hello :)
thank you for this project! I have a little problem with AES decipher Buffer and i hope you have an idea, what i am doing wrong...
Example:
MySQL table with AES_ENCRYPT for username and password
Node.js:
sending query:
SELECT * FROM Accounts;
Then I get such values for password and username:
->
<Buffer 07 86 95 ee 77 df 86 50 ae 18 4c d5 3e 48 42 75
How to decode it? My tries failed all... to deciper something should look like this:
I hope AES-128-ECB is choosen correctly...
The text was updated successfully, but these errors were encountered: