【问题标题】:Convert 'String' to Base64 encode of MD5 'String' in c# .net在c#.net中将'String'转换为MD5'String'的Base64编码
【发布时间】:2015-11-15 12:31:44
【问题描述】:

如何将我的密码“字符串”转换为 MD5“字符串”的 Base64 编码。像这个字符串 'password' 到 'X03MO1qnZdYdgyfeuILPmQ=='。

请帮帮我

或者只是让我知道如何将此“密码”转换为“X03MO1qnZdYdgyfeuILPmQ==”的技术。我自己写代码

【问题讨论】:

  • 在这种情况下 btoa('password') = "cGFzc3dvcmQ=" 。我需要输出“X03MO1qnZdYdgyfeuILPmQ=="
  • 看看this
  • 我明白了吗,您想使用 MD5 对字符串 password 进行编码,然后将结果转换为 Base64?
  • 是的,你是对的。我试过了,但我的答案不同于 'X03MO1qnZdYdgyfeuILPmQ=='
  • @ZaidIqbal 我发布了答案,试试吧。

标签: c# .net base64 md5 password-encryption


【解决方案1】:

好的,有例子(vb.net,我会尝试使用一些在线转换器在 c# 中转换):

Dim pwd As String = "password"
Dim hs As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create
Dim db As Byte() = hs.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pwd))
Dim result As String = Convert.ToBase64String(db)

字符串 password 将产生 X03MO1qnZdYdgyfeuILPmQ==

更新:使用在线转换器转换为 c#(我希望它正确转换)

string pwd = "password";
System.Security.Cryptography.MD5 hs = System.Security.Cryptography.MD5.Create;
byte[] db = hs.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pwd));
string result = Convert.ToBase64String(db);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-10
    • 2012-07-24
    • 2012-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多