Code example for NoSuchAlgorithmException

Methods: getMessage

0
  public synchronized String encrypt(String plain) throws Exception {
    MessageDigest md = null;
    try { 
      md = MessageDigest.getInstance("SHA");
    } catch (NoSuchAlgorithmException e) {
      throw new Exception(e.getMessage());
    } 
 
    try { 
      md.update(plain.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new Exception(e.getMessage());
    } 
 
    byte raw[] = md.digest();
    String hash = (new BASE64Encoder()).encode(raw);
    return hash;
  } 
 
  public static synchronized PasswordService getInstance() { 
Connect your IDE to all the code out there  Get Codota for Java