Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function Sha256_Base64(ByVal ClearString As String, ByVal base64 As Boolean) As String
- Dim sha256x As SHA256 = SHA256Managed.Create()
- Dim bytes As Byte() = Encoding.UTF8.GetBytes(ClearString)
- Dim hash As Byte() = sha256x.ComputeHash(bytes)
- Dim stringBuilder As New StringBuilder()
- For i As Integer = 0 To hash.Length - 1
- stringBuilder.Append(hash(i).ToString("x2"))
- Next
- If base64 = True Then
- Return Convert.ToBase64String(hash)
- Else
- Return stringBuilder.ToString()
- End If
- Return Nothing
- End Function
Advertisement
Add Comment
Please, Sign In to add comment