如何使用Challenge Key进行MD5加密 [英] How to MD5 encrypt using Challenge Key

查看:125
本文介绍了如何使用Challenge Key进行MD5加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MD5身份验证建立与服务器的连接。

服务器返回挑战密钥,,,,

如何使用它来加密我的密码并将其发送回服务器....

目前我所知的加密方法需要密码哈希,盐键和VI代码...

如何我可以制作,,,,请帮助朋友......



I am trying to establish a connection to a Server using MD5 Authentication.
The server returns me the challenge key,,,,
How can I use it to encrypt my password and send it back to the server....
The encryption method currently I know needs Password Hash, Salt Key, and VI Code...
How Can I make it ,,,, Please Help friends...

static readonly string PasswordHash = "PasswordHash";
        static readonly string SaltKey = "SaltKey";
        static readonly string VIKey = "@1B2c3D4e5F6g7H8";

        public static string Encrypt(string plainText)
        {
            byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);

            byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256 / 8);
            var symmetricKey = new RijndaelManaged() { Mode = CipherMode.CBC, Padding = PaddingMode.Zeros };
            var encryptor = symmetricKey.CreateEncryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));

            byte[] cipherTextBytes;

            using (var memoryStream = new MemoryStream())
            {
                using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
                {
                    cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
                    cryptoStream.FlushFinalBlock();
                    cipherTextBytes = memoryStream.ToArray();
                    cryptoStream.Close();
                }
                memoryStream.Close();
            }
            return Convert.ToBase64String(cipherTextBytes);
        }

推荐答案

MD5不是加密算法 - 它是一种散列算法。最大的区别是加密可以逆转,哈希不能。因此,一旦您对密码进行了哈希处理(以某种方式与挑战密钥相结合),您的密码就无法从您与服务器共享的信息中获得。使用MD5非常简单 - 谷歌MD5 C#MSDN你应该知道如何做到这一点,但至于在你的具体情况下如何使用它的实际机制,我们无法帮助。



您需要与运行服务器的人员(或编码服务器上运行的软件的人员)交谈,以确切了解如何将密码与挑战密钥结合使用,因为没有正确的方法要做到这一点,机制中的任何细微差别都会产生无法正常工作的MD5值。



抱歉,我们无法帮助您 - 只有服务器人们可以。
MD5 is not an encryption algorithm - it is a hashing algorithm. The big difference is that encryption can be reversed, hashing can't. So once you have hashed your password (combined with the challenge key in some way) your password cannot be derived from the information you share with the server. Using MD5 is pretty simple - google "MD5 C# MSDN" and you should find out how to do it, but as for the actual mechanics of how to use it in your specific case we cannot help.

You need to talk to the people running the server (or who coded the software running on the server) to find out exactly how you combine your password with the challenge key because there is no "one right way" to do it, and any slight different in the mechanism will produce a MD5 value that fails to work.

Sorry, but we can't help you - only the server people can.


这篇关于如何使用Challenge Key进行MD5加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆