mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-06-08 23:57:45 +00:00
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.
21 lines
510 B
Java
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);
|
|
}
|
|
}
|