I have the following code to encrypt/decrypt data in node.js, which is working:
var cipher = crypto.createCipher(\'aes256\', \'passphrase\');
var encrypted = c
From the node.js source I found this:
bool CipherInit(char* cipherType, char* key_buf, int key_buf_len) {
cipher = EVP_get_cipherbyname(cipherType);
if(!cipher) {
fprintf(stderr, "node-crypto : Unknown cipher %s\n", cipherType);
return false;
}
unsigned char key[EVP_MAX_KEY_LENGTH],iv[EVP_MAX_IV_LENGTH];
int key_len = EVP_BytesToKey(cipher, EVP_md5(), NULL,
(unsigned char*) key_buf, key_buf_len, 1, key, iv);
I found a c# implementation of EVP_BytesToKey in this question which can be used like this:
byte[] key, iv;
DeriveKeyAndIV(Encoding.ASCII.GetBytes("passphrase"),null, 1, out key, out iv);
//this is what node.js gave me as the base64 encrypted data
var encrytedBytes = Convert.FromBase64String("b3rbg+mniw7p9aiPUyGthg==");
The key and IV can then be used in an instance of RijndaelManaged
to decrypt encrytedBytes