1 package com.atlassian.activeobjects.util;
2
3 import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
4 import static org.apache.commons.lang3.StringUtils.right;
5
6 /**
7 * <p>A digester that creates an hexadecimal representation of the md5 sum of the String it applies to.</p>
8 * <p>Note: the String is considered {@code UTF-8} encoded for any tranformation to and from {@link byte bytes}.</p>
9 */
10 public final class HexMd5Digester implements Digester {
11 public String digest(String s) {
12 return md5Hex(s);
13 }
14
15 public String digest(String s, int n) {
16 return right(digest(s), n);
17 }
18 }