suculent / thinx-aes-lib

AES wrapper for ESP8266/ESP32/Arduino/nRF5x
Other
113 stars 39 forks source link

Text from nodemcu to nodejs #16

Closed kchatzatogou closed 4 years ago

kchatzatogou commented 4 years ago

Hello there, I would like to mention this is NOT an issue, just a request for assistance!

Initially i would like to thank you for the library and the code you have provided. You have a nodejs example which is working fine. My question is how i can produce the ei6NxsBeWk7hj41eia3S0Od26goTtxHvwO6V27LwSW4= (nodejs string to decrypt from your examples) from c++ (from the examples you have provide)? In other words i wild like to get the encrypted string and put in nodejs for testing I will appreciate any kind of assist. Thx for your time

suculent commented 4 years ago
var CryptoJS = require("crypto-js");
var plaintext = "HELLO";
var plaintext_b64 = Buffer.from(plaintext).toString('base64');
iv = CryptoJS.enc.Hex.parse(plain_iv); // reset IV back to 0
var ebytes = CryptoJS.AES.encrypt( plaintext_b64, key, { iv: iv } );
var ciphertext = ebytes.toString();
console.log("ciphertext: ", ciphertext);
kchatzatogou commented 4 years ago

Hello there and happy new year, I probably did not explain well my issue. I would like to get string ei6NxsBeWk7hj41eia3S0Od26goTtxHvwO6V27LwSW4= in arduino (c++) in order to send it in nodejs in order to decrypt it. Again thanks for your time

suculent commented 4 years ago

See examples/complex.

First you need to set aes_key and enc_iv (must be same on both MCU/Server sides). You can then use convenience method encrypt() or call aes.encrypt() on your own.

String encrypted = encrypt(cleartext, enc_iv); sprintf(ciphertext, "%s", encrypted.c_str());

    1. 2020 v 11:38, kchatzatogou notifications@github.com:

Hello there and happy new year, I probably did not explain well my issue. I would like to get string ei6NxsBeWk7hj41eia3S0Od26goTtxHvwO6V27LwSW4= in arduino (c++) in order to send it in nodejs in order to decrypt it. Again thanks for your time

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

kchatzatogou commented 4 years ago

Thx for your time.