Silverlight C#中的MD5或其他加密。

| 我正在尝试对用于登录系统的密码字段进行加密,因此我想对加密进行匹配,以确保用户输入了正确的详细信息。 由于某些原因,Silverlight中Security.Cryptography没有MD5服务,因此我不得不寻找另一种方法。 我以前曾用过:
public string Md5Encrypt(string originalPassword)
        {
            //Declarations
            Byte[] originalBytes;
            Byte[] encodedBytes;
            MD5 md5;

            //Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
            md5 = new MD5CryptoServiceProvider();
            originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
            encodedBytes = md5.ComputeHash(originalBytes);

            //Convert encoded bytes back to a \'readable\' string
            return BitConverter.ToString(encodedBytes);
        }
但是现在不起作用。 谁能给我一个简单的示例,说明Silverlight C#中有效的加密方法 谢谢     
已邀请:
您可以在silverlight中简单地使用Using HashLib:http://hashlib.codeplex.com/(在HashLib.HashFactory.HashCryptoNotBuildIn命名空间内查看) BouncyCastle.Crypt 1.7版本也具有Silverlight 2.0及更高版本,其中可以使用大多数加密/哈希功能:http://www.bouncycastle.org/csharp/ 最后,Mono源代码始终在这里为您提供帮助:https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Security.Cryptography/SHA512Managed.cs如果目标是.NET 2.0或更高版本,请将任何Cypto代码复制到您的项目中。     

要回复问题请先登录注册