@Test public void testHash() { byte[] key = TypeUtils.fromHexString("00112233445566778899AABBCCDDEEFF"); assertEquals(16, key.length); String clientKey = Base64.getEncoder().encodeToString(key); String serverHash = AcceptHash.hashKey(clientKey); assertEquals("mVL6JKtNRC4tluIaFAW2hhMffgE=", serverHash); }
public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(Base64Utils.encode(md.digest())); } catch (Exception e) { throw new EncodingAcceptHashKeyException("", e); } }
AcceptHash { public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(Base64Utils.encode(md.digest())); } catch (Exception e) { throw new EncodingAcceptHashKeyException("", e); } } }
AcceptHash { public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(Base64Utils.encode(md.digest())); } catch (Exception e) { throw new EncodingAcceptHashKeyException("", e); } }  }
AcceptHash { public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(Base64Utils.encode(md.digest())); } catch (Exception e) { throw new EncodingAcceptHashKeyException("", e); } }  static String hashKey(String key); }
AcceptHash { public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(Base64Utils.encode(md.digest())); } catch (Exception e) { throw new EncodingAcceptHashKeyException("", e); } }  static String hashKey(String key);  }