问问题
23 次
1 回答
0
我找到了解决方案:
代码是:
Imports Replicon.Cryptography.SCrypt
Imports System.Globalization
Imports System.Text
Public Class Form1
Public Shared Function Btog(ByVal ba() As Byte) As String
Dim hex As StringBuilder = New StringBuilder(ba.Length * 2)
Dim b As Byte
For Each b In ba
hex.AppendFormat("{0:x2}", b)
Next
Return hex.ToString()
End Function
Public Function HexDecode(ByVal s As String) As Byte()
Return HexDecode(s, 0)
End Function
Public Function HexDecode(ByVal s As String, ByVal paddingBytes As Integer) As Byte()
If s Is Nothing Then
Throw New ArgumentNullException("s")
End If
If s.IndexOf(":"c) > -1 Then
s = s.Replace(":", "")
End If
If (s.Length Mod 2) <> 0 Then
Throw New FormatException("parameter 's' must have an even number of hex characters")
End If
Dim result As Byte() = New Byte(s.Length \ 2 + (paddingBytes - 1)) {}
For i As Integer = 0 To result.Length - paddingBytes - 1
result(i) = Byte.Parse(s.Substring(i * 2, 2), NumberStyles.AllowHexSpecifier)
Next
Return result
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RichTextBox1.Text = Btog(SCrypt.DeriveKey(HexDecode(TextBox1.Text), HexDecode(TextBox1.Text), 1024, 1, 1, 32))
End Sub
End Class
于 2021-12-20T16:42:55.877 回答