2019-02-07 22:39:33 +01:00
|
|
|
package com.beemdevelopment.aegis.encoding;
|
2018-02-10 17:20:41 +01:00
|
|
|
|
2019-12-26 20:47:28 +01:00
|
|
|
import com.google.common.io.BaseEncoding;
|
|
|
|
|
2018-02-10 17:20:41 +01:00
|
|
|
public class Hex {
|
|
|
|
private Hex() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-26 20:47:28 +01:00
|
|
|
public static byte[] decode(String s) throws EncodingException {
|
|
|
|
try {
|
|
|
|
return BaseEncoding.base16().decode(s.toUpperCase());
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
throw new EncodingException(e);
|
2018-02-10 17:20:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 18:33:38 +01:00
|
|
|
public static String encode(byte[] data) {
|
2019-12-26 20:47:28 +01:00
|
|
|
return BaseEncoding.base16().lowerCase().encode(data);
|
2018-02-10 17:20:41 +01:00
|
|
|
}
|
|
|
|
}
|