Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    private static final String SHA_256 = "SHA-256";

    public static byte[] simpleHash256(byte[] msg) throws NoSuchAlgorithmException {
        MessageDigest sha256 = MessageDigest.getInstance(SHA_256);
        byte[] byteHolder1, byteHolder2;
        byteHolder1 = sha256.digest(msg);
        for (int i = 0; i < 100; i++) {
            byteHolder2 = sha256.digest(byteHolder1);
            byteHolder1 = sha256.digest(byteHolder2);
        }
        return byteHolder1;
    }
}