@Test public void hash() { String input1 = "somekey"; HashGeneratorStrategy hasher = new HashGeneratorStrategy(); String output1 = hasher.hash(input1); String output2 = hasher.hash(input1); Assert.assertNotSame(output1, output2); }
public String hash(final String inInput) { Random generator = new Random(); String input = inInput + Integer.toString(generator.nextInt()); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(input.getBytes()); byte[] messageDigest = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(TWO_FIFTY_FIVE & messageDigest[i])); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { log.error("hash failed"); return null; } }
HashGeneratorStrategy { public String hash(final String inInput) { Random generator = new Random(); String input = inInput + Integer.toString(generator.nextInt()); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(input.getBytes()); byte[] messageDigest = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(TWO_FIFTY_FIVE & messageDigest[i])); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { log.error("hash failed"); return null; } } }
HashGeneratorStrategy { public String hash(final String inInput) { Random generator = new Random(); String input = inInput + Integer.toString(generator.nextInt()); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(input.getBytes()); byte[] messageDigest = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(TWO_FIFTY_FIVE & messageDigest[i])); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { log.error("hash failed"); return null; } }  }
HashGeneratorStrategy { public String hash(final String inInput) { Random generator = new Random(); String input = inInput + Integer.toString(generator.nextInt()); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(input.getBytes()); byte[] messageDigest = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(TWO_FIFTY_FIVE & messageDigest[i])); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { log.error("hash failed"); return null; } }  String hash(final String inInput); }
HashGeneratorStrategy { public String hash(final String inInput) { Random generator = new Random(); String input = inInput + Integer.toString(generator.nextInt()); try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(input.getBytes()); byte[] messageDigest = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(TWO_FIFTY_FIVE & messageDigest[i])); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { log.error("hash failed"); return null; } }  String hash(final String inInput);  }