n0s3c

Untitled

Jun 18th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.63 KB | None | 0 0
  1.     Public Function Sha256_Base64(ByVal ClearString As String, ByVal base64 As Boolean) As String
  2.         Dim sha256x As SHA256 = SHA256Managed.Create()
  3.         Dim bytes As Byte() = Encoding.UTF8.GetBytes(ClearString)
  4.         Dim hash As Byte() = sha256x.ComputeHash(bytes)
  5.         Dim stringBuilder As New StringBuilder()
  6.         For i As Integer = 0 To hash.Length - 1
  7.             stringBuilder.Append(hash(i).ToString("x2"))
  8.         Next
  9.         If base64 = True Then
  10.             Return Convert.ToBase64String(hash)
  11.         Else
  12.             Return stringBuilder.ToString()
  13.         End If
  14.         Return Nothing
  15.     End Function
Advertisement
Add Comment
Please, Sign In to add comment