Algunas versiones de org.bouncycastle.jce.provider.BouncyCastleProvider tienen vulnerabilidades.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import org.bouncycastle.jce.provider.BouncyCastleProvider; import java.security.MessageDigest; import java.security.Security; public class MD4Example { public static void main(String[] args) throws Exception { Security.addProvider(new BouncyCastleProvider()); String password = "mypassword"; byte[] bytes = password.getBytes("UTF-16LE"); MessageDigest md = MessageDigest.getInstance("MD4"); byte[] hash = md.digest(bytes); // Convertir el hash a una cadena hexadecimal StringBuilder hexString = new StringBuilder(); for (byte b : hash) { String hex = Integer.toHexString(0xff & b); if (hex.length() == 1) { hexString.append('0'); } hexString.append(hex); } System.out.println("Hash MD4: " + hexString.toString()); } } |