comm_sense Posted February 18 Posted February 18 Hello In integration with a bank, it is required to encode base64 with the SHA-512 algorithm. How can I get the results I got from the bank's samples in Unigui? C# example String hashVal = "1234"; System.Security.Cryptography.SHA512 sha = new System.Security.Cryptography.SHA512CryptoServiceProvider(); byte[] hashbytes = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(hashVal); byte[] inputbytes = sha.ComputeHash(hashbytes); String hashValue = System.Convert.ToBase64String(inputbytes); Visual Basic example: Dim result As Byte() Dim sha As New System.Security.Cryptography.SHA512Managed() Dim hashval As String = "1234" result = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(hashval)) Dim hashValue As String = Convert.ToBase64String(result) For the data "1234", the result I obtained with the C# and Visual Basic examples: 1ARVn2Auq2/WAqx2gNrL+q3RNjAzXpUfCXrzkA6d4Xa22yhRLy4AC50E+6UTPoscbo31nbOoq51gvkuXzJ6B2w== Quote
mazluta Posted February 18 Posted February 18 check with : https://www.chilkatsoft.com/refdoc/delphidll.asp Quote
Ron Posted February 22 Posted February 22 uses System.NetEncoding, System.Hash; function getB64SHA512(s:string):string; var LSHA512: THashSHA2; Base64: TBase64Encoding; begin LSHA512 := THashSHA2.Create; Base64 := TBase64Encoding.Create; result := Base64.EncodeBytesToString(LSHA512.GetHashBytes(s, SHA512)); end; Result using s='1234': 1ARVn2Auq2/WAqx2gNrL+q3RNjAzXpUfCXrzkA6d4Xa22yhRLy4AC50E+6UTPoscbo31nbOoq51gvkuXzJ6B2w== SHA512 options are SHA512, SHA512_224, SHA512_256 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.