C#加密库 Elixis
<div id="p_fullcontent" class="detail"> <p>Elixis 是一个C#的加密啊库,支持 AES、TripleDES和MD5 算法的加密和解密(MD5是单向的),而且更多加密的算法还在进一步开发中。</p> <p>示例代码:</p> <p></p> <pre class="brush:c#; toolbar: true; auto-links: false;">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(); }</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1328023110530" target="_blank">http://www.open-open.com/lib/view/home/1328023110530</a></p> <p></p> </div>
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!