0

I'm wondering if anyone can suggest a good way to replicate the following openssl command line in .NET? I'm not looking for someone to write the code, just suggest the best method to use. I have RijndaelManaged working doing AES 256 CBC mode and can base64 encode it, etc. But, I'm unclear on how openssl is generating\using "salt" - is the salt a part of the result base64 encoded output?

$ echo 1234 | openssl enc -aes-256-cbc -a -salt -pass pass:<passphrase>

Any pointers to decent documentation on openssl commandline? (I don't see salt or aes-256-cbc on http://openssl.org/docs/apps/openssl.html )

EDIT:

OK, found the documentation for openssl enc at http://openssl.org/docs/apps/enc.html# - just trying to grok it. :)

EDIT2:

I think this is closer to what I am needing ( http://deusty.blogspot.com/2009/04/decrypting-openssl-aes-files-in-c.html )

Julien Roncaglia
  • 17,397
  • 4
  • 57
  • 75
mutex
  • 7,536
  • 8
  • 45
  • 66

3 Answers3

1

The answers to openssl des3 decrypting in java should get you going.

Community
  • 1
  • 1
Jumbogram
  • 2,249
  • 1
  • 20
  • 24
1

OpenSSL is basically some dlls with and executable over them. There is an old project OpenSSL.Net on sourceforge to bind them in C# maybe you could start there.

Julien Roncaglia
  • 17,397
  • 4
  • 57
  • 75
  • upvote since this is a decent option. I would prefer to stick to using the .net framework crypto classes though. – mutex Mar 27 '11 at 20:26
  • Actually I'm going to mark this as answer, since it probably would have been the sensible way to do it. Finally got it working how I wanted though :) http://stackoverflow.com/questions/5452422/openssl-using-only-net-classes/5454692#5454692 – mutex Mar 28 '11 at 04:30
0

You can also achieve this with OpenSSL Library for .NET

DidiSoft.OpenSsl.OpenSslCipher cipher = new DidiSoft.OpenSsl.OpenSslCipher();
bool isBase64 = true;
string encrypted = cipher.EncryptString(CipherAlgorithm.Aes_256_Cfb, "1234", 
                                        "<passphrase>", isBase64);

Disclaimer: I work for DidiSoft