ElixisC#加密库
Elixis 是一个C#的加密啊库,支持 AES、TripleDES和MD5 算法的加密和解密(MD5是单向的),而且更多加密的算法还在进一步开发中。
示例代码:
private static AESEncryptor fAESEncryptor = new AESEncryptor("My Password", AESBits.BITS256);
private static TripleDESEncryptor fTripleDESEncryptor = new TripleDESEncryptor("My Password");
private static MD5Encryptor fMD5Encryptor = new MD5Encryptor();
static void Main(string[] args)
{
string originalText = "Hello! This is Elixis...";
Console.WriteLine("AES Encryption n ");
// Encrypt with AES.
string encryptedAESString = fAESEncryptor.Encrypt(originalText);
Console.WriteLine("Encrypted AES: " + encryptedAESString);
// Decrypt with AES.
string decryptedAESString = fAESEncryptor.Decrypt(encryptedAESString);
Console.WriteLine("Decrypted AES: " + decryptedAESString);
Console.WriteLine("nnTripleDES Encryption n ");
// Encrypt with TripleDES.
byte[] tripleDESEncryptedString = fTripleDESEncryptor.Encrypt(Encoding.ASCII.GetBytes(originalText));
Console.WriteLine("Encrypted TripleDES: " + Encoding.Default.GetString(tripleDESEncryptedString));
// Decrypt with TripleDES.
byte[] tripleDESDecryptedString = fTripleDESEncryptor.Decrypt(tripleDESEncryptedString);
Console.WriteLine("Decrypted TripleDES: " + Encoding.Default.GetString(tripleDESDecryptedString));
Console.WriteLine("nnMD5 Encryption n ");
// Encrypt with MD5.
string md5 = fMD5Encryptor.GetMD5(originalText);
Console.WriteLine("MD5: " + md5);
string md5_bytes = fMD5Encryptor.GetMD5(Encoding.ASCII.GetBytes(originalText));
Console.WriteLine("MD5_bytes: " + md5_bytes);
Console.Read();
}