Java Digest digestString(String pass, String algorithm)

Here you can find the source of digestString(String pass, String algorithm)

Description

digest String

License

Apache License

Declaration

public static String digestString(String pass, String algorithm) throws NoSuchAlgorithmException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String digestString(String pass, String algorithm) throws NoSuchAlgorithmException {
        MessageDigest md;//from   w  w  w. j  a  v a2 s  . c  o  m
        ByteArrayOutputStream bos;
        md = MessageDigest.getInstance(algorithm);
        byte[] digest = md.digest(pass.getBytes());
        return new String(digest);
    }
}

Related

  1. digestInit()
  2. digestOperation(String algo, byte[]... content)
  3. digestStream(MessageDigest digest, InputStream is)
  4. digestString(MessageDigest md, String s)
  5. digestString(String input)
  6. digestString(String pass, String algorithm)
  7. digestThenEncodePasswordForLDAP(String algorithm, String credentials)
  8. digestWithSalt(String password, byte[] salt, String algorithm)