ElixisC#加密库

联合创作 · 2023-09-30 08:22

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();
}

浏览 9
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报