fernet-java8 icon indicating copy to clipboard operation
fernet-java8 copied to clipboard

Crash on android 7 and lower

Open laxuscullen opened this issue 3 years ago • 2 comments

I have read the open and closed issues regarding this but I am still very lost. I am using java. I need to only decrypt the cipher in android.

Crash error: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64;

Code:

final Key keyEn = new Key(keyString);
final Token token = Token.fromString(encryptedString);
final Validator < String > validator = new StringValidator() {
    public TemporalAmount getTimeToLive() {
        return Duration.ofSeconds(Instant.MAX.getEpochSecond());
    }
};

mediaUrl = token.validateAndDecrypt(keyEn, validator);

It works fin above 7 but crashes instantly on first line in android 7 and lower. I could really use some help on this, if possible. Thank you so much!

laxuscullen avatar Apr 03 '22 07:04 laxuscullen

@l0s sorry for bothering mate, I am in a pinch here and you are the only one who can help. So trying my luck for the last time by tagging you. Apologies once again.

laxuscullen avatar Apr 04 '22 04:04 laxuscullen

@laxuscullen you won't be able to use any of the methods that accept a base64-encoded String. Instead, you'll need to use the Android-native utility to convert the base64 String into a byte array, then use the corresponding byte array methods. See the example I provided here: https://github.com/l0s/fernet-java8/issues/478#issuecomment-1027611555 .

If you still have issues, can you share a minimal working project that reproduces the problem?

l0s avatar Apr 05 '22 05:04 l0s