c# 谁能帮我把这句VB代码翻译成c#的呢
'这里用的是ascii编码密码原文,如果要用汉字做密码,可以用UnicodeEncoding,但会与ASP中的MD5函数不兼容DimdataToHashAsByte()=...
'这里用的是ascii编码密码原文,如果要用汉字做密码,可以用UnicodeEncoding,但会与ASP中的MD5函数不兼容
Dim dataToHash As Byte() = (New System.Text.ASCIIEncoding).GetBytes(strSource)
Dim hashvalue As Byte() = CType(System.Security.Cryptography.CryptoConfig.CreateFromName("MD5"), System.Security.Cryptography.HashAlgorithm).ComputeHash(dataToHash) '选择位字符的加密结果
Dim strResult As String = "" Dim i As Integer
For i = 4 To 11
strResult += Hex(hashvalue(i)).ToLower
Next Return strResult 展开
Dim dataToHash As Byte() = (New System.Text.ASCIIEncoding).GetBytes(strSource)
Dim hashvalue As Byte() = CType(System.Security.Cryptography.CryptoConfig.CreateFromName("MD5"), System.Security.Cryptography.HashAlgorithm).ComputeHash(dataToHash) '选择位字符的加密结果
Dim strResult As String = "" Dim i As Integer
For i = 4 To 11
strResult += Hex(hashvalue(i)).ToLower
Next Return strResult 展开
2013-12-13
展开全部
byte[] dataToHash = (new System.Text.ASCIIEncoding()).GetBytes(strSource);
byte[] hashvalue = (System.Security.Cryptography.HashAlgorithm)System.Security.Cryptography.CryptoConfig.CreateFromName("MD5").ComputeHash(dataToHash);
//选择位字符的加密结果
string strResult = "";
int i;
for (i = 4; i <= 11; i++) {
strResult += Conversion.Hex(hashvalue(i)).ToLower;
}
return strResult;
byte[] hashvalue = (System.Security.Cryptography.HashAlgorithm)System.Security.Cryptography.CryptoConfig.CreateFromName("MD5").ComputeHash(dataToHash);
//选择位字符的加密结果
string strResult = "";
int i;
for (i = 4; i <= 11; i++) {
strResult += Conversion.Hex(hashvalue(i)).ToLower;
}
return strResult;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询