encrypt SHA - Android java.security

Android examples for java.security:Sha

Description

encrypt SHA

Demo Code


//package com.java2s;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {

    public static byte[] encryptSHA(byte[] data) {
        MessageDigest sha = null;
        try {/*from   w  w w .java  2s .  co m*/
            sha = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        sha.update(data);
        return sha.digest();
    }
}

Related Tutorials