嗨,大家好,我是这个论坛的新手,也是C#的初学者
我有一个代码可以在vb.net,bt中生成密钥,因为sm原因我切换到了c#,需要将vb.net编码转换为c#
我在线上对其进行了转换,它对我不起作用:请看一下编码
我认为问题是c#无法识别的ASC和HEX。希望我能在这里得到解决方案。
提前致谢
我有一个代码可以在vb.net,bt中生成密钥,因为sm原因我切换到了c#,需要将vb.net编码转换为c#
我在线上对其进行了转换,它对我不起作用:请看一下编码
C#:
Public Function GenCode(ByVal strUN As String) As String
Dim P1 As Long, P2 As Long, P3 As Long
Dim S1 As String, S2 As String, S3 As String
Dim j As Integer
For j = 1 To Len(strUN)
P1 = P1 + Asc(Mid(strUN, j, 1)) * 15
Next
strUN = LCase(strUN)
For j = 1 To Len(strUN)
P2 = P2 + Asc(Mid(strUN, j, 1)) * 20
Next
strUN = UCase(strUN)
For j = 1 To Len(strUN)
P3 = P3 + Asc(Mid(strUN, j, 1)) * 25
Next
S1 = CStr(Hex(P1))
S2 = CStr(Hex(P2))
S3 = CStr(Hex(P3))
If Len(S1) > 4 Then S1 = Left(S1, 4)
If Len(S2) > 4 Then S2 = Left(S2, 4)
If Len(S3) > 4 Then S3 = Left(S3, 4)
GenCode = S1 & "-" & S2 & "-" & S3
End Function
我认为问题是c#无法识别的ASC和HEX。希望我能在这里得到解决方案。
提前致谢