重新开始并不是一个选项,因为已经运行的项目使用SHA-256
这里是java代码--->>>只是一个简单的代码来散列任何字符串
public static String SHA256 (String text) throws NoSuchAlgorithmException, UnsupportedEncodingException
{
textByte = text.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("SHA-256");
textByte = md.digest(textByte);
return Base64.encodeToString(textByte,Base64.NO_CLOSE);
}
和VB代码如下
Public Function EncryptPassword(ByVal password As String) As String
Dim hashedPassword As String = Nothing
Dim hashProvider As SHA256Managed = Nothing
Try
Dim passwordBytes() As Byte
passwordBytes = System.Text.Encoding.Unicode.GetBytes(password)
hashProvider = New SHA256Managed
hashProvider.Initialize()
passwordBytes = hashProvider.ComputeHash(passwordBytes)
hashedPassword = Convert.ToBase64String(passwordBytes)
Catch ex As Exception
Finally
If Not hashProvider Is Nothing Then
hashProvider.Clear()
hashProvider = Nothing
End If
End Try
Return hashedPassword
End Function
答案 0 :(得分:2)
嗯,它可能不是唯一的问题,但VB中的System.Text.Encoding.Unicode是UTF-16LE,而您的Java代码使用的是UTF-8。