Calculate MD5 in Base64 encoding - Android java.security

Android examples for java.security:MD5

Description

Calculate MD5 in Base64 encoding

Demo Code

import android.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main{

    public static final String md5base64(byte buffer[])
            throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("MD5");
        digest.update(buffer);// ww  w  .j a v  a2  s  . c om
        byte buf2[] = digest.digest();
        return Base64.encodeToString(buf2, Base64.NO_WRAP
                | Base64.NO_PADDING | Base64.NO_CLOSE);
    }

}

Related Tutorials