l0s/fernet-java8

Crash on android 7 and lower

Closed this issue · 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!

@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.

l0s commented

@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: #478 (comment) .

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