@Test public void testRfcHashExample() { String clientKey = "dGhlIHNhbXBsZSBub25jZQ=="; String serverAccept = AcceptHash.hashKey(clientKey); String expectedHash = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="; assertEquals(expectedHash, serverAccept); }
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);  }