The java.lang.String class does not provide a faster way to code the MD5 algorithm, surely for security reasons.
Here a quick way to do implement is a a static class
1.import java.security.MessageDigest;
2.import java.security.NoSuchAlgorithmException;
3.
4.public class LMD5Gen {
5.
6. public static String md5(String input){
7. String res = "";
8. try {
9. MessageDigest algorithm = MessageDigest.getInstance("MD5");
10. algorithm.reset();
11. algorithm.update(input.getBytes());
12. byte[] md5 = algorithm.digest();
13. String tmp = "";
14. for (int i = 0; i < md5.length; i++) {
15. tmp = (Integer.toHexString(0xFF & md5[i]));
16. if (tmp.length() == 1) {
17. res += "0" + tmp;
18. } else {
19. res += tmp;
20. }
21. }
22. } catch (NoSuchAlgorithmException ex) {}
23. return res;
24. }
25.
26.}
José Ferreiro's ホセ フェレイロ (Хосе Ферреиро) research, analysis, management experiences, Information Technology trends, competitive intelligence and life stories...
Thursday, October 28, 2010
Sunday, October 17, 2010
Middleware : Service-Oriented Architectures (SOA) using BPEL components
Future is the next generation of Business Integration through Service-Oriented Architecture (SOA). Legacy integration technologies are too complex and require proprietary skills to develop, support, and maintain. Standards have cleared the path to develop truly composite applications that leverage existing technology investments, promote mainstream developer adoption, and adapt to future technological advances.
Subscribe to:
Posts (Atom)