以下代码在windows 8.1和10中运行良好,并在windows xp sp3中进行了测试--它不工作并返回空值,在sha1中也有相同的问题,但是MD5运行良好,并获得返回输出,但其他人不能,windows xp sp3支持沙校验和函数还是需要任何特殊代码(对不起,英语很差)
Public Function GetSha512Hash()
Dim _flexe$ = ""
Dim _result$ = ""
Try
_flexe$ = IO.Path.Combine(Application.ExecutablePath)
Using _sha512 As New System.Security.Cryptography.SHA512CryptoServiceProvider
Using stream = File.OpenRead(_flexe$)
Dim _hash = _sha512.ComputeHash(stream)
_result$ = BitConverter.ToString(_hash).Replace("-", String.Empty)
Trace.WriteLine(String.Format("{0}", _result$))
Return _result$
End Using
End Using
Catch ex As Exception
Trace.WriteLine(Err.Description)
Me.PEx = ex
Return _result$
End Try
End Function
'SHa384
Public Function GetSha384Hash()
Dim _flexe$ = ""
Dim _result$ = ""
Try
_flexe$ = IO.Path.Combine(Application.ExecutablePath)
Using _sha512 As New System.Security.Cryptography.SHA384CryptoServiceProvider
Using stream = File.OpenRead(_flexe$)
Dim _hash = _sha512.ComputeHash(stream)
_result$ = BitConverter.ToString(_hash).Replace("-", String.Empty)
Trace.WriteLine(String.Format("{0}", _result$))
Return _result$
End Using
End Using
Catch ex As Exception
Trace.WriteLine(Err.Description)
Me.PEx = ex
Return _result$
End Try
End Function发布于 2017-09-01 11:43:57
发布于 2017-09-01 13:27:06
最后我得到了一些关于SHA1、SHA1CryptoServiceProvider、SHA1Managed和SHA1Cng类在.NET中的区别的信息..。
https://stackoverflow.com/questions/45999464
复制相似问题