Skip to content

Instantly share code, notes, and snippets.

View jaketarnow's full-sized avatar

Jake Tarnow jaketarnow

  • San Francisco, CA
View GitHub Profile
@jaketarnow
jaketarnow / CryptoOne.java
Created May 31, 2016 21:38
Given a variable integer X (e.g. 42) and a string word (e.g. "hello"), where word is iteratively run through a SHA-256 hex digest computation X number of times, what is the resulting hex digest?
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class CryptoOne {
public static String getHash(String word, int x) throws NoSuchAlgorithmException {
String oldWord = word;
String newWord = null;
MessageDigest digest = MessageDigest.getInstance("SHA-256");
for (int i = 0; i < x; i++) {
if (newWord != null) {