使用gnu-crypto jar使用whirlpool算法加密pwd的Java示例 [英] Java example for encrypting pwd with whirlpool algorithm using gnu-crypto jar
问题描述
我想使用gnu.crypto.hash.Whirlpool哈希来加密字符串。
I want to encrypt a String using gnu.crypto.hash.Whirlpool hashing.
加密应加密密码并应返回加密的密码。
加密(pwd);
The encrypt should encrypt the password and should return the encrypted pwd. encrypt(pwd);
此方法应该实现使用gnu jar和whirlpool加密pwd
散列算法
应该等于以下网站生成的密码
http://hash.online-convert.com/whirlpool-generator
我尝试使用下面的代码但是我我无法获得类似于生成的漩涡网站的512字节代码:
I tried with the code below but I am unable to get the 512 byets code similar to the whirlpool site generated:
import gnu.crypto.hash.HashFactory;
import gnu.crypto.hash.IMessageDigest;
public class EncryptPwdWithAPI{
public static void main(String arg[])
{
encrypt("somepwd");
}
public static String encrypt(String password)
{
IMessageDigest md = HashFactory.getInstance("WHIRLPOOL");
md.update(input, 0, input.length);
byte[] digest = md.digest();
System.out.println( "Input : "+new String(input)+ "\nPWD : "+new String(digest)
}
}
推荐答案
雅正确但我期待漩涡hascode,512字节,等于在线哈希码生成器生成的代码。我得到了预期的输出 JacksumAPI 。
Ya correct but i was expecting whirlpool hascode with 512 bytes which is equal to the code generated by the online hashcode generator. I got the intended output with JacksumAPI.
以下是一些代码:
import java.security.NoSuchAlgorithmException;
import jonelo.jacksum.JacksumAPI;
import jonelo.jacksum.algorithm.AbstractChecksum;
public class JacksumTest {
public static void main(String arg[])
{
String password = "somepwd";
AbstractChecksum checksum = null;
try {
checksum = JacksumAPI.getChecksumInstance("whirlpool");
checksum.update(password.getBytes());
System.out.println(checksum.getFormattedValue());
} catch (NoSuchAlgorithmException nsae) { }
}
}
这篇关于使用gnu-crypto jar使用whirlpool算法加密pwd的Java示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!