有人可以将此Hashing方法从C#转换为VB吗?

Met*_*uru 0 c# vb.net

  public static string CalculateSHA1(string text, Encoding enc)
{
    byte[] buffer = enc.GetBytes(text);
    SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider();
    string hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");
    return hash;
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

VStudio一直对我大吼大叫,因为我到目前为止最具体的是Byte末尾的括号?:

Private Sub CalculateSHA1(ByVal text As String, ByVal enc As Encoding)
    Dim buffer As Byte[] = enc.GetBytes(text);

End Sub
Run Code Online (Sandbox Code Playgroud)

And*_*are 8

这个怎么样?

Public Shared Function CalculateSHA1(text As String, enc As Encoding) As String
    Dim buffer As Byte() = enc.GetBytes(text)
    Dim cryptoTransformSHA1 As New SHA1CryptoServiceProvider()
    Dim hash As String = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "")
    Return hash
End Function
Run Code Online (Sandbox Code Playgroud)

VB.NET不[]用于数组,而是使用它().