Android Question HMACSHA256 Decryption

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi, I have an encrypted text
How can I decrypt it?

Hash Function => HMACSHA 256
text => "test TEXT for coding"
key => "12345"
Hashed Output => "656F4247466CD5876A72AB41D23398AD646F51DC06F8E5D71236A42063801A7B"


I made this code as follows
B4X:
Dim message As String
    Dim secret_key As String

    message="test TEXT for coding"
    secret_key="12345"
 
   
    Dim k As KeyGenerator
    k.Initialize("HMACSHA256")
    k.KeyFromBytes(secret_key.GetBytes("UTF8"))
   
    Dim m As Mac
    m.Initialise("HMACSHA256", k.Key)
    m.Update(message.GetBytes("UTF8"))
   
   
    Dim b() As Byte
    b = m.Sign

    Log("text  => "&message)
    Log("key  => "&secret_key)
    Log("Hash Function  => "&"HMACSHA 256")
   
    Dim bc As ByteConverter
    Log("Hashed Output  => "&bc.HexFromBytes(b))
 

SMOOTSARA

Active Member
Licensed User
Longtime User
Hash = one directional function. In this case it is used to verify the integrity of the original message. A bit like an extended version of checksum.
It is not an encrypted version of the message.


Thank you for your response

How to convert the same hash text to the first one (in b4X)?

656F4247466CD5876A72AB41D23398AD646F51DC06F8E5D71236A42063801A7B => test TEXT for coding
 
Upvote 0
Top