I have this base 64 string:
It is derived from encoding a SHA256 hex string to a base 64 string. When I use attached sample code to get the sha256 hex string I get the following:
It seems to me as if the decoding should use ISO8859_1 and not UTF8 else I don't get a string that are 256 bits long / a string with 64 hex chars)
Question is - am I doing it correctly (i.e the reverse calc)? The hex string should be 64 chars long as it was a sha256 string that was converted to a base64 string.
B4X:
1KYOvzAp1tmGmGTdHEsODQ61aqVHf3AORGjLDEf58Jw=
It is derived from encoding a SHA256 hex string to a base 64 string. When I use attached sample code to get the sha256 hex string I get the following:
B4X:
D4A60EBF3029D6D9869864DD1C4B0E0D0EB56AA5477F700E4468CB0C47F9F09C
It seems to me as if the decoding should use ISO8859_1 and not UTF8 else I don't get a string that are 256 bits long / a string with 64 hex chars)
Question is - am I doing it correctly (i.e the reverse calc)? The hex string should be 64 chars long as it was a sha256 string that was converted to a base64 string.
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
Dim MyBase64String As String = "1KYOvzAp1tmGmGTdHEsODQ61aqVHf3AORGjLDEf58Jw="
Dim MyBase64StringAsBytes() As Byte = su.DecodeBase64(MyBase64String)
Log("LENGTE = " & MyBase64StringAsBytes.Length)
Dim s As String = BytesToString(MyBase64StringAsBytes, 0, MyBase64StringAsBytes.Length, "ISO8859_1")
Log ("S = " & s)
Dim ss As String = StringToHex(s)
Log(ss)
End Sub
Sub StringToHex(StrToHex As String) As String
Dim bc As ByteConverter
Return bc.HexFromBytes(StrToHex.GetBytes("ISO8859_1"))
End Sub