common_helper/src/main/java/com/xiongyingqi/util/MD5Crypt.java
static public final String crypt(String password) {
        StringBuffer salt = new StringBuffer();
        java.util.Random rnd = new java.util.Random();

        // build a random 8 chars salt
        while (salt.length() < 8) {
            int index = (int) (rnd.nextFloat() * SALTCHARS.length());
            salt.append(SALTCHARS.substring(index, index + 1));
        }

        // crypt
        return crypt(password, salt.toString(), "$1$");
    }
static public final String crypt(String password) {
        StringBuffer salt = new StringBuffer();
        java.util.Random rnd = new java.util.Random();

        // build a random 8 chars salt
        while (salt.length() < 8) {
            int index = (int) (rnd.nextFloat() * SALTCHARS.length());
            salt.append(SALTCHARS.substring(index, index + 1));
        }

        // crypt
        return crypt(password, salt.toString(), "$1$");
    }
static public final String crypt ( String password ) { StringBuffer salt = new StringBuffer ( ) ; java . util . Random rnd = new java . util . Random ( ) ; // build a random 8 chars salt while ( salt . length ( ) < 8 ) { int index = ( int ) ( rnd . nextFloat ( ) * SALTCHARS . length ( ) ) ; salt . append ( SALTCHARS . substring ( index , index + 1 ) ) ; } // crypt return crypt ( password , salt . toString ( ) , "$1$" ) ; }
LINUX/BSD MD5Crypt function

@param password Password to be encrypted
@return The encrypted password as an MD5 hash
LINUX / BSD MD5Crypt function