I am trying to get same result as tool webnet77.
http://webnet77.com/cgi-bin/helpers/blowfish.pl
I am using info for tool-
ALGORITM = "Blowfish";
HEX KEY = "92514c2df6e22f079acabedce08f8ac3";
PLAIN_TEXT = "sangasong@song.com"
Tool returns-
CD3A08381467823D4013960E75E465F0B00C5E3BAEFBECBB
I tried with java code with value -
final String ALGORITM = "Blowfish";
final String KEY = "92514c2df6e22f079acabedce08f8ac3";
final String PLAIN_TEXT = "sangasong@song.com";
byte[] decodedHex = DatatypeConverter.parseHexBinary(KEY);
byte[] keyInBase64 = Base64.decodeBase64(decodedHex);
String meth = hexToString(KEY);
MessageDigest sha = MessageDigest.getInstance("SHA-1");
Key skey = new javax.crypto.spec.SecretKeySpec(raw, "AES");
try {
byte[] encrypted = encrypt(decodedHex, PLAIN_TEXT);
System.out.println( "Encrypted hex: " + Hex.encodeHexString(encrypted));
byte[] encrypted1 = encrypt(keyInBase64, PLAIN_TEXT);
System.out.println( "Encrypted byte64: " + Hex.encodeHexString(encrypted1));
byte[] encrypted2 = encrypt(meth.getBytes(), PLAIN_TEXT);
System.out.println( "Encrypted method: " + Hex.encodeHexString(encrypted2));
} catch (GeneralSecurityException e) {
e.printStackTrace();
}
private static byte[] encrypt(byte[] key, String plainText) throws GeneralSecurityException {
SecretKey secret_key = new SecretKeySpec(key, "Blowfish");
Cipher cipher = Cipher.getInstance("Blowfish");
cipher.init(Cipher.ENCRYPT_MODE, secret_key);
return cipher.doFinal(plainText.getBytes());
}
Result -
Encrypted hex: 525bd4bd786a545fe7786b0076b3bbc2127425f0ea58c29d
Encrypted byte64: 1a2abceed959cef8f5b2dcb668069c1580d736dda0832703
Encrypted method: 2c87b7682091053ad1bdf945368f959b5edf064b58499e18
Please help to get result same as tool.
thanks a lot.