Created
October 27, 2017 09:57
-
-
Save RCasatta/53322f876e4f6c4acec0963e39273d3d to your computer and use it in GitHub Desktop.
Recursive sha256
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.eternitywall; | |
| import javax.xml.bind.DatatypeConverter; | |
| import java.security.MessageDigest; | |
| import java.security.NoSuchAlgorithmException; | |
| import java.util.Random; | |
| public class Main { | |
| public static void main(String[] args) { | |
| try { | |
| byte[] b = new byte[32]; | |
| new Random().nextBytes(b); | |
| MessageDigest md = MessageDigest.getInstance("SHA-256"); | |
| long start = System.currentTimeMillis(); | |
| for(long l=0;l<1000000000;l++) { | |
| if(l%10000000==0) { | |
| String s = DatatypeConverter.printHexBinary(b).toLowerCase(); | |
| long elapsedNanos = (System.currentTimeMillis()-start)*1000; | |
| System.out.println(l + " " + s + " " + ((double) l / (double) elapsedNanos) + " Mhash/s"); | |
| } | |
| md.update(b); | |
| b = md.digest(); | |
| md.reset(); | |
| } | |
| } catch (NoSuchAlgorithmException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment