@Test public void testGenerate_defaultMD5() { TokenStringGenerator generator = new TokenStringGenerator(); String value = generator.generate("hoge"); assertThat(value, is(notNullValue())); assertThat(value.length(), is(32)); }
public String generate(final String seed) { if (seed == null) { throw new IllegalArgumentException("seed must not be null"); } long time = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(1000); sb.append(internalSeed).append(seed).append(time).append(counter .getAndIncrement()); MessageDigest md = createMessageDigest(); md.update(sb.toString().getBytes()); byte[] bytes = md.digest(); return toHexString(bytes); }
TokenStringGenerator { public String generate(final String seed) { if (seed == null) { throw new IllegalArgumentException("seed must not be null"); } long time = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(1000); sb.append(internalSeed).append(seed).append(time).append(counter .getAndIncrement()); MessageDigest md = createMessageDigest(); md.update(sb.toString().getBytes()); byte[] bytes = md.digest(); return toHexString(bytes); } }
TokenStringGenerator { public String generate(final String seed) { if (seed == null) { throw new IllegalArgumentException("seed must not be null"); } long time = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(1000); sb.append(internalSeed).append(seed).append(time).append(counter .getAndIncrement()); MessageDigest md = createMessageDigest(); md.update(sb.toString().getBytes()); byte[] bytes = md.digest(); return toHexString(bytes); } TokenStringGenerator();  TokenStringGenerator(final String algorithm); }
TokenStringGenerator { public String generate(final String seed) { if (seed == null) { throw new IllegalArgumentException("seed must not be null"); } long time = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(1000); sb.append(internalSeed).append(seed).append(time).append(counter .getAndIncrement()); MessageDigest md = createMessageDigest(); md.update(sb.toString().getBytes()); byte[] bytes = md.digest(); return toHexString(bytes); } TokenStringGenerator();  TokenStringGenerator(final String algorithm); String generate(final String seed); }
TokenStringGenerator { public String generate(final String seed) { if (seed == null) { throw new IllegalArgumentException("seed must not be null"); } long time = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(1000); sb.append(internalSeed).append(seed).append(time).append(counter .getAndIncrement()); MessageDigest md = createMessageDigest(); md.update(sb.toString().getBytes()); byte[] bytes = md.digest(); return toHexString(bytes); } TokenStringGenerator();  TokenStringGenerator(final String algorithm); String generate(final String seed); static final String DEFAULT_ALGORITHM; }