I started only a few days ago trying to figure this out under "questions". Go there for an explanation of what I am trying to do.
I've been reading a lot and I learned a little bit more about what command and line does what and why... I am still trying to get a preferred output, but not getting it. Here's what I have so far trying to test to see if I can generate the first 17 hashes from consecutive 16 digit hexidecimal number from 0x0 to 0x10 and I am wondering why it isn't working... explanations with // below of what I try to do with each line:
import java.security.MessageDigest; public class SHAHashingExample { public static void main(String[] args) { String a = "0000000000000000"; // here is where I am converting a string to an integer so I can make it a loop for (int b = Integer.parseInt(a); b <= 17; b++); { for (int c=0; c <= b; c++); { // here is where I am wanting it to print the first original hex value System.out.println("Original : " + c); } //below is the set up for the hash MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(a.getBytes()); byte byteData[] = md.digest(); //convert the byte to hex format StringBuffer hexString = new StringBuffer(); for (int i=0;i<byteData.length;i++) { String hex=Integer.toHexString(0xff & byteData[i]); if(hex.length()==1) hexString.append('0'); hexString.append(hex); } //here is where it outputs the hash of the original System.out.println("Hash : " + hexString.toString()); } //Here is a line separator for it to print a blank line between the first Hash and the next Original System.out.printlm("") } }
But I still get:
Original: 0000000000000000
Hash: fcdb4b423f4e5283afa249d762ef6aef150e91fccd810d43e5 e719d14512dec7
<blank line>
When I want:
Original: 0000000000000000
Hash: fcdb4b423f4e5283afa249d762ef6aef150e91fccd810d43e5 e719d14512dec7
<blank line>
Original: 0000000000000001
Hash: 665e994827f6b03167e80c1513eb356e0d4f013f2e03a3b345 e1e5e3c24dfca6
-----and so on until...-----
Original: 0000000000000010
Hash: fb4714aaedd1c0f5682d402c31131f1f85a57236e4f47cd111 acf596e3241ab4
It's not looping correctly to give me the output I want and I am not sure where I am going wrong. Is what I want to do impossible with java language or do I just not know enough yet? Or what specifically am I missing or have out of place to make it generate the multiple outputs I want? Any help would be appreciated.