20
Views
6
Comments
[HMAC-SHA256 Encryption] Error when input string
hmac-sha256-v3-xif
Reactive icon
Forge component by Mostafa Othman
Application Type
Reactive

There is a errror when I input string into the GetEncryptedValue function, would you please help to check and fix, thanks

Hi Jack, 

Thank you for contacting me. I will check and get back to you soon 

Thank you for your reply, feel free to let me know if you need more information on the error. 


@Jack Wong the I had you exact error message using this component. The problem was that the extension assumes the key is in hex, so it does a conversion first looking for pairs of hex characters (which is where the error message comes from). If you just replace the "HexDecode" call with a "StringEncode" instead on the key in the main method, this forge component works well for plaintext keys also.

Thank you @Charles Jessop  for your reply, actually you let me checking back for this component which I didn't touch for long time and also it gives me an opportunity to apologize to @Jack Wong  for not answering him for long time. 

As Charles said you getting this error because you are trying to use plain text not hexadecimal and this application built to encrypt data that sent to one payment gateways provider which providing key in hexadecimal format for example:

message: amount=100¤cy=EUR

Key: 57617b5d2349434b34734345635073433835777e2d244c31715535255a366773755a4d70532a5879793238235f707c4f7865753f3f446e633a21575643303f66

Expected result: 

b436e3e86cb3800b3864aeecc8d06c126f005e7645803461717a8e4b2de3a905


In Case you used StringEncode instead of HexDecode using same message and key above it will give different result.


I am thinking about adding one more parameter to my action to indicate if key is hexadecimal or plain text and based on that parameter we can use HexDecode method or StringEncode method.

Makes perfect sense to me Mostafa. I think this is a really useful extension (saved me a bunch of time writing the extension myself!), but since there's no requirement for the key to be in hex, as you say might be worth having multiple parameters with useful variable names to flag to people what type of key to provide.

Its my pleasure to know that extension helped you.

I updated extension by adding one more parameter that allows who will use extension to select type of key either hexadecimal or plain text.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.