Example usage for org.apache.commons.codec.digest DigestUtils md5

List of usage examples for org.apache.commons.codec.digest DigestUtils md5

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils md5.

Prototype

public static byte[] md5(String data) 

Source Link

Usage

From source file:com.mindquarry.management.user.UserManagementClient.java

public static void main(String[] args) {
    log = LogFactory.getLog(UserManagementClient.class);
    log.info("Starting user management client..."); //$NON-NLS-1$

    // parse command line arguments
    CommandLine line = null;//from   w  ww. ja va 2 s .  c o  m
    CommandLineParser parser = new GnuParser();
    try {
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (ParseException e) {
        // oops, something went wrong
        log.error("Parsing of command line failed."); //$NON-NLS-1$
        printUsage();
        return;
    }
    // retrieve login data
    System.out.print("Please enter your login ID: "); //$NON-NLS-1$

    String user = readString();
    user = user.trim();

    System.out.print("Please enter your new password: "); //$NON-NLS-1$

    String password = readString();
    password = password.trim();
    password = new String(DigestUtils.md5(password));
    password = new String(Base64.encodeBase64(password.getBytes()));

    // start PWD change client
    UserManagementClient manager = new UserManagementClient();
    try {
        if (line.hasOption(O_DEL)) {
            manager.deleteUser(line.getOptionValue(O_REPO), ADMIN_LOGIN, ADMIN_PWD, user, password);
        } else {
            manager.changePwd(line.getOptionValue(O_REPO), ADMIN_LOGIN, ADMIN_PWD, user, password);
        }
    } catch (Exception e) {
        log.error("Error while applying password changes.", e); //$NON-NLS-1$
    }
    log.info("User management client finished successfully."); //$NON-NLS-1$
}

From source file:Main.java

public static String md5Hex(String input) {
    return new String(Hex.encodeHex(DigestUtils.md5(input)));
}

From source file:Main.java

public static byte[] multiMD5(byte[] data) {
    byte[] res = DigestUtils.md5(data);
    int headLength = res.length / 2;
    byte[] head = new byte[headLength];

    if (res.length > headLength) {
        byte[] tail = new byte[res.length - headLength];

        System.arraycopy(res, 0, head, 0, headLength);
        System.arraycopy(res, headLength, tail, 0, tail.length);
        head = DigestUtils.md5(head);//from w  w  w .  j a v a 2 s . c  o m
        tail = DigestUtils.md5(tail);
        res = new byte[head.length + tail.length];
        System.arraycopy(head, 0, res, 0, head.length);
        System.arraycopy(tail, 0, res, head.length, tail.length);
    }

    res = DigestUtils.md5(res);

    return res;
}

From source file:com.jive.myco.seyren.core.util.hashing.TargetHash.java

public static String create(String target) {
    if (target == null) {
        return null;
    }/*ww w  . ja v  a 2s .  c o m*/
    return new String(DigestUtils.md5(target));
}

From source file:com.seyren.core.util.hashing.TargetHash.java

public static String create(String target) {
    if (target == null) {
        return null;
    }//from  ww  w  .ja v a 2  s  .c  o m
    return new String(DigestUtils.md5(target), Charset.forName("UTF-8"));
}

From source file:dtu.ds.warnme.app.utils.SecurityUtils.java

public static String hashMD5Base64(String stringToHash) {
    if (StringUtils.isEmpty(stringToHash)) {
        return StringUtils.EMPTY;
    }/*from  w  w  w .  j  a  va 2s . c  o m*/
    try {
        byte[] bytes = stringToHash.getBytes(CHARSET_UTF8);
        byte[] sha512bytes = DigestUtils.md5(bytes);
        byte[] base64bytes = Base64.encodeBase64(sha512bytes);
        return new String(base64bytes, CHARSET_UTF8);
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "This system does not support required hashing algorithms.", e);
        throw new IllegalStateException("This system does not support required hashing algorithms.", e);
    }
}

From source file:mvm.rya.indexing.accumulo.Md5Hash.java

public static String md5Base64(byte[] data) {
    return Base64.encodeBase64URLSafeString(DigestUtils.md5(data));
}

From source file:DigestUsage.java

public void start() {

    String hashData = "Hello World!!";

    System.err.println("Hello World!! as MD5 16 element hash: " + new String(DigestUtils.md5(hashData)));

    System.err.println("Hello World!! as MD5 Hex hash: " + DigestUtils.md5Hex(hashData));

    System.err.println("Hello World!! as SHA byte array hash: " + new String(DigestUtils.sha(hashData)));

    System.err.println("Hello World!! as SHA Hex hash: " + DigestUtils.shaHex(hashData));

}

From source file:name.martingeisse.phunky.runtime.builtin.string.hash.Md5Function.java

@Override
protected byte[] hash(final byte[] data) {
    return DigestUtils.md5(data);
}

From source file:mvm.rya.indexing.accumulo.Md5Hash.java

public static byte[] md5Binary(Value value) {
    return DigestUtils.md5(value.get());
}