Wednesday, November 21, 2012

Crypted Jelly Bean fix

Android v4.2 changed default provider for SecureRandom. Because of that the Cipher throws this exception on v4.2: BadPaddingException: pad block corrupted.

The solution is quite simple. Just add explicitly specified provider as the second parameter of the SecureRandom.getInstance() method:

 SecureRandom sr = SecureRandom.getInstance( "SHA1PRNG", "Crypto" );

Read more here

No comments:

Post a Comment