CRAM-MD5 Sasl机制实现

时间:2013-05-17 12:23:39

标签: .net cryptography sasl

我想实现CRAM-MD5 sasl机制的使用,我正在查看System.Security.Cryptography.HMACMD5,但不知道从哪里开始。可以任何人帮助我,教程文章欢迎任何事情。

Public Function CRAMMD5Credentials(ByVal userName As String, ByVal password As String, ByVal b64challenge As String) As String
    Dim cram As New System.Security.Cryptography.HMACMD5(System.Text.Encoding.ASCII.GetBytes(password))
    Dim challenge As String = System.Text.Encoding.ASCII.GetString(System.Convert.FromBase64String(b64challenge))
    Dim digest As String = System.Text.Encoding.ASCII.GetString(cram.ComputeHash(System.Text.Encoding.ASCII.GetBytes(challenge)))
    Return System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(userName & " " & digest.ToLower))
End Function

1 个答案:

答案 0 :(得分:0)

到目前为止你做了什么? CRAM-MD5甚至在维基百科(http://en.wikipedia.org/wiki/CRAM-MD5)中进行了清晰描述,并在相应的RFC(RFC 2095,RFC 2195)中进行了更详细的描述