SHA in Java and testing tool
My company has project that use Java & SHA as the algorithm to encrypt the password
MessageDigest md = MessageDigest.getInstance(开发者_Go百科"SHA");
QA should use which tool to test this SHA algorithm. I search on Google and just found SHA-1, SHA-2 not found SHA.
"SHA" is a synonym for SHA-1. You can see it by debugging and inspecting the MessageDigest instance or just by comparing the results of digesting the same string with each of them:
MessageDigest sha = MessageDigest.getInstance("SHA");
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
String shaString = new BASE64Encoder().encode(sha.digest("foobarbaz".getBytes()));
String sha1String = new BASE64Encoder().encode(sha1.digest("foobarbaz".getBytes()));
System.out.println(shaString);
System.out.println(sha1String);
outputs
X1UT+IIv2+UUWvM7ZNjZcNz5XG4=
X1UT+IIv2+UUWvM7ZNjZcNz5XG4=
You get the same exact MessageDigest algorithm whether you spec "SHA" or "SHA-1".
精彩评论