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
It is inside a QR code - my understanding is that the body/message of the QR code was converted to a SHA256 and the SHA256 was converted to a Base64 string.
It goes as follows:
1. Scan the QR Code - then decode scanned string. The decoded string looks as follows:
3. So, it seems to me there is another Base64 code (1KYOvzAp1tmGmGTdHEsODQ61aqVHf3AORGjLDEf58Jw=) which is in all probability the SHA256 that was encoded to base64.
4. With the project that I have attached am trying to get back to the original SHA256 (hex string) from 1KYOvzAp1tmGmGTdHEsODQ61aqVHf3AORGjLDEf58Jw=
5. So, I get this after the reversal: D4A60EBF3029D6D9869864DD1C4B0E0D0EB56AA5477F700E4468CB0C47F9F09C