Public Function strtobase64(s) As String
Dim a As Byte() = System.Text.Encoding.UTF8.GetBytes(s)
Return Convert.ToBase64String(a)
End Function
Public Function base64tostr(s) As String
Dim b As Byte() = Convert.FromBase64String(s)
Return System.Text.Encoding.UTF8.GetString(b)
End Function
Public Function MD5(ByVal StrSource As String) As String
Dim md5Hasher As New MD5CryptoServiceProvider()
Dim data As Byte() = md5Hasher.ComputeHash(Encoding.Default.GetBytes(StrSource))
Dim sBuilder As New StringBuilder()
Dim i As Integer
For i = 0 To data.Length - 1
sBuilder.Append(data(i).ToString("x2"))
Next i
Return sBuilder.ToString().Substring(0, 32)
End Function
Public Function PinYinGet(ByVal t1 As String) As String
On Error Resume Next
Dim sOne, sChar, sRet As String, i As Integer
For i = 1 To Len(t1)
sChar = Mid(t1, i, 1)
sOne = ""
If Asc(sChar) > 0 Then
If UCase(sChar) <= "Z" And UCase(sChar) >= "A" Then
sOne = UCase(sChar)
Else
sOne = "" '=sChar
End If
ElseIf Asc(sChar) >= Asc("啊") And Asc(sChar) < Asc("芭") Then
sOne = "A"
ElseIf Asc(sChar) >= Asc("芭") And Asc(sChar) < Asc("擦") Then
sOne = "B"
ElseIf Asc(sChar) >= Asc("擦") And Asc(sChar) < Asc("搭") Then
sOne = "C"
ElseIf Asc(sChar) >= Asc("搭") And Asc(sChar) < Asc("蛾") Then
sOne = "D"
ElseIf Asc(sChar) >= Asc("蛾") And Asc(sChar) < Asc("发") Then
sOne = "E"
ElseIf Asc(sChar) >= Asc("发") And Asc(sChar) < Asc("噶") Then
sOne = "F"
ElseIf Asc(sChar) >= Asc("噶") And Asc(sChar) < Asc("哈") Then
sOne = "G"
ElseIf Asc(sChar) >= Asc("哈") And Asc(sChar) < Asc("击") Then
sOne = "H"
ElseIf Asc(sChar) >= Asc("击") And Asc(sChar) < Asc("喀") Then
sOne = "J"
ElseIf Asc(sChar) >= Asc("喀") And Asc(sChar) < Asc("垃") Then
sOne = "K"
ElseIf Asc(sChar) >= Asc("垃") And Asc(sChar) < Asc("妈") Then
sOne = "L"
ElseIf Asc(sChar) >= Asc("妈") And Asc(sChar) < Asc("拿") Then
sOne = "M"
ElseIf Asc(sChar) >= Asc("拿") And Asc(sChar) < Asc("哦") Then
sOne = "N"
ElseIf Asc(sChar) >= Asc("哦") And Asc(sChar) < Asc("啪") Then
sOne = "O"
ElseIf Asc(sChar) >= Asc("啪") And Asc(sChar) < Asc("期") Then
sOne = "P"
ElseIf Asc(sChar) >= Asc("期") And Asc(sChar) < Asc("然") Then
sOne = "Q"
ElseIf Asc(sChar) >= Asc("然") And Asc(sChar) < Asc("撒") Then
sOne = "R"
ElseIf Asc(sChar) >= Asc("撒") And Asc(sChar) < Asc("塌") Then
sOne = "S"
ElseIf Asc(sChar) >= Asc("塌") And Asc(sChar) < Asc("挖") Then
sOne = "T"
ElseIf Asc(sChar) >= Asc("挖") And Asc(sChar) < Asc("昔") Then
sOne = "W"
ElseIf Asc(sChar) >= Asc("昔") And Asc(sChar) < Asc("压") Then
sOne = "X"
ElseIf Asc(sChar) >= Asc("压") And Asc(sChar) < Asc("匝") Then
sOne = "Y"
ElseIf Asc(sChar) >= Asc("匝") Then
sOne = "Z"
End If
sRet = sRet & sOne
Next i
Return sRet
End Function
VB.NET BASE64转字符串和MD5获取和拼音首字母
于 2020-03-11 13:35:41 首次发布