Je tente d'effectuer un appel XML-RPC qui nécessite le hachage HmacSHA-256 d'une chaîne particulière. Je suis actuellement en utilisant la bibliothèque Jasypt avec le code suivant:Stockage de mot de passe SHA2 avec Java
StandardPBEStringEncryptor sha256 = new StandardPBEStringEncryptor();
sha256.setPassword(key);
sha256.setAlgorithm("PBEWithHmacSHA2");
En essayant d'utiliser sha256.encrypt (string) Je reçois cette erreur:
Exception in thread "main" org.jasypt.exceptions.EncryptionInitializationException: java.security.NoSuchAlgorithmException: PBEWithHmacAndSHA256 SecretKeyFactory not available at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:597) at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:488) at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.encrypt(StandardPBEStringEncryptor.java:541) at nysenateapi.XmlRpc.main(XmlRpc.java:52) Caused by: java.security.NoSuchAlgorithmException: PBEWithHmacAndSHA256 SecretKeyFactory not available at javax.crypto.SecretKeyFactory.(DashoA13*..) at javax.crypto.SecretKeyFactory.getInstance(DashoA13*..) at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:584) ... 3 more
J'ai téléchargé l'extension Cryptographie et placé JCE les pots dans mon buildpath, mais cela ne semble pas avoir fait quoi que ce soit. J'ai essayé d'utiliser un certain nombre de combinaisons dans setAlgorithm ci-dessus, y compris "PBE", "PBEWithSha" (1 | 2 | 128 | 256) ?, "PBEWithHmacSha", etc.
J'ai également essayé d'utiliser BouncyCastle mais je n'ai pas Je n'ai pas de chance non plus. Toute aide ou conseil apprécié!
Une fonction de résumé de message n'est pas une fonction de cryptage. – rook
Merci pour la clarification. – Jared