1 package com.calipso.reportgenerator.reportmanager; 2 3 import com.calipso.reportgenerator.common.InfoException; 4 import com.calipso.reportgenerator.common.LanguageTraslator; 5 6 import java.security.MessageDigest ; 7 8 11 12 public class PasswordEncryptor { 13 14 19 public static String getEncryptedPassword(String password) throws InfoException { 20 StringBuffer buffer = new StringBuffer (); 21 try { 22 byte [] encrypt = password.getBytes("UTF-8"); 23 MessageDigest md = MessageDigest.getInstance("SHA"); 24 md.update(encrypt); 25 byte [] hashedPasswd = md.digest(); 26 for(int i = 0 ; i < hashedPasswd.length ; i++) { 27 buffer.append(Byte.toString(hashedPasswd [i])); 28 } 29 } catch(Exception e) { 30 throw new InfoException(LanguageTraslator.traslate("474"),e); 31 } 32 return buffer.toString(); 33 } 34 } 35 | Popular Tags |