开发者

SHA in Java and testing tool

开发者 https://www.devze.com 2023-03-25 10:11 出处:网络
My company has project that use Java & SHA as the algorithm to encrypt the password MessageDigest md = MessageDigest.getInstance(开发者_Go百科\"SHA\");

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".

0

精彩评论

暂无评论...
验证码 换一张
取 消