Skip to content Skip to sidebar Skip to footer

HmacSHA256 Algorithm In Android API 23

I am trying to generate hash value in my Android app (API 23). I followed this link- https://developer.android.com/reference/javax/crypto/Mac.html and below code should work as per

Solution 1:

You typed the algorithm incorrectly It's HmacSHA256 not hmacSHA256

You need to be careful when choosing the algorithms because they're case sensitive.

From your snapshot I can see that you used

Mac hmacSHA256 = Mac.getInstance("hmacSHA256");

It's incorrect because you're trying to get the instance of hmacSHA256 witch does not exists!

The correct one would be

Mac hmacSHA256 = Mac.getInstance("HmacSHA245");

The first H should be on caps


Post a Comment for "HmacSHA256 Algorithm In Android API 23"