just follow up my previous post : http://baiduhix.blogspot.com/2018/05/android-cipher-aes-256-cbc.html
when you try to use cipher in android to encrypt, you may get below error:
java.security.InvalidKeyException: Illegal key size or default parameters
this is because you are trying to do 256 encryption which default java doesn't support. you will need to change your jce:
For java8 user, you can download from here: (other java version please find your jce accordingly):
then replace “local_policy.jar ”“US_export_policy.jar” into your jre lib.
if you are using mac your jre is here:
then you need to put “local_policy.jar ”“US_export_policy.jar” into:
However, this doen't help. you still get the same error.
that because your android studio is not using this jre, it has a build in jre which is here:
so replace “local_policy.jar ”“US_export_policy.jar” here.
Unfortunately , you still cannot run this code. you need to change your gradle:
unitTests.returnDefaultValues = true
after that you can run the code. but you will get: null for result.
That because you are trying to run it in your android studio with junit. these code works on android.