Android SHA1 Hash Create sha512(String what_to_encode)

Here you can find the source of sha512(String what_to_encode)

Description

sha

Declaration

public static String sha512(String what_to_encode) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String sha512(String what_to_encode) {
        final MessageDigest sha512;
        try {//from   w  w w  .  java  2  s  . c  om
            sha512 = MessageDigest.getInstance("SHA-512");
        } catch (NoSuchAlgorithmException e) {
            return "404";
        }
        sha512.update(what_to_encode.getBytes());
        byte byteData[] = sha512.digest();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16)
                    .substring(1));
        }
        return sb.toString();
    }
}

Related

  1. SHA1(String str)
  2. SHA1(String text)
  3. dataDigest(String in)
  4. SHA1(String s)
  5. SHA1(String text)