1
2
3
4 package org.andromda.timetracker.security;
5
6 import java.io.UnsupportedEncodingException;
7 import java.security.MessageDigest;
8 import java.security.NoSuchAlgorithmException;
9
10
11
12
13
14 public class PasswordEncoder
15 {
16
17
18
19
20
21
22 public static String getMD5Base64EncodedPassword(String plaintext)
23 throws NoSuchAlgorithmException, UnsupportedEncodingException
24 {
25 MessageDigest md = MessageDigest.getInstance("MD5");
26 md.update(plaintext.getBytes("UTF8"));
27 byte raw[] = md.digest();
28 String hash = new sun.misc.BASE64Encoder().encode(raw);
29 return hash;
30 }
31 }