@Override
 public String toString() {
   final StringBuilder sb = new StringBuilder();
   sb.append("ExtensionDescriptor");
   sb.append("{bytes=").append(bytes == null ? "null" : Hex.encodeHex(bytes));
   sb.append('}');
   return sb.toString();
 }
Ejemplo n.º 2
0
 public static String digest(HmacAlgorithms algorithm, String key, String str) {
   if (str == null) {
     return null;
   }
   try {
     SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF-8"), algorithm.value);
     Mac mac = Mac.getInstance(algorithm.value);
     mac.init(secretKey);
     char[] hexB = Hex.encodeHex(mac.doFinal(str.getBytes("UTF-8")));
     return new String(hexB);
   } catch (InvalidKeyException
       | NoSuchAlgorithmException
       | IllegalStateException
       | UnsupportedEncodingException e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 3
0
 private static String hexEncode(byte[] bytes) {
   return new String(Hex.encodeHex(bytes));
 }