: I have not been able to get the actual SHA implementation (SHA-1,
: SHA-256...) from the MessageDigest instance. If we could get that, I
: suspect it would be different on my machine then yours.

How about this...

import java.security.MessageDigest;
public final class Temp {
  public static void main(String[] args) throws Exception {
    final byte[] INPUT = "How now brown Cow?".getBytes("UTF-8");
    final String[] ALGOS =  new String[]{"SHA", "SHA-1", "SHA-256", 
"SHA-512"};
    final byte[][] OUTPUT = new byte[ALGOS.length][];
    for (int a = 0; a < ALGOS.length; a++) {
      final MessageDigest d = MessageDigest.getInstance(ALGOS[a]);
      d.update(INPUT);
      OUTPUT[a] = d.digest();
    }
    for (int x = 0; x < ALGOS.length; x++) {
      for (int y = 0; y < ALGOS.length; y++) {
        System.out.println(ALGOS[x] +
                           (MessageDigest.isEqual(OUTPUT[x], OUTPUT[y]) ? " == 
" : " != ") +
                           ALGOS[y]);
      }
    }
  }
}


hossman@tray:~/tmp$ javac Temp.java 
hossman@tray:~/tmp$ java -ea Temp
SHA == SHA
SHA == SHA-1
SHA != SHA-256
SHA != SHA-512
SHA-1 == SHA
SHA-1 == SHA-1
SHA-1 != SHA-256
SHA-1 != SHA-512
SHA-256 != SHA
SHA-256 != SHA-1
SHA-256 == SHA-256
SHA-256 != SHA-512
SHA-512 != SHA
SHA-512 != SHA-1
SHA-512 != SHA-256
SHA-512 == SHA-512





-Hoss
http://www.lucidworks.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to