Aegis/app/src/main/java/com/beemdevelopment/aegis/encoding/Hex.java
Alexander Bakker 10ac1af6b0 Replace implementations of Base16, Base32 and Base64 with Guava
I kept the classes in the encoding package and turned them into wrappers for
Guava. I also changed the functions in the Base32 class to take and return
strings insteads if character arrays.
2020-02-01 14:11:55 +01:00

21 lines
510 B
Java

package com.beemdevelopment.aegis.encoding;
import com.google.common.io.BaseEncoding;
public class Hex {
private Hex() {
}
public static byte[] decode(String s) throws EncodingException {
try {
return BaseEncoding.base16().decode(s.toUpperCase());
} catch (IllegalArgumentException e) {
throw new EncodingException(e);
}
}
public static String encode(byte[] data) {
return BaseEncoding.base16().lowerCase().encode(data);
}
}