javax.crypto

PBKDF2WithHmacSHA512 Vs. PBKDF2WithHmacSHA1

最后都变了- 提交于 2019-11-27 10:33:49
问题 I'm working on a Java authentication subsystem that specs the storage of passwords in the DB as PBKDF2 -generated hashes, and I'm now trying to decide whether I should use SHA1 or SHA512 as PFR. I went through the specs of both but they are very mathematically intensive for me to follow. Can somebody with better crypto-understanding explain how PBKDF2WithHmacSHA512 differs from PBKDF2WithHmacSHA1 ? Here's what I'm trying to do: private static final int HASH_BYTE_SIZE = 64; // 512 bits private

Why am I getting package javax.crypto does not exist

流过昼夜 提交于 2019-11-27 06:38:16
问题 When I compile a class using javax.crypto.Mac I get this error message? package javax.crypto does not exist I can fix it by including jre/lib/jce.jar in my compile classpath. Why is jce.jar not on the default jdk classpath? jre/lib/rt.jar is on the classpath, and includes other javax packages, but jce seems special? 回答1: OK, this was a mistake on my part. The Ant file I was using to compile the code had this attribute on the javac task: bootclasspath="${java.home}/lib/rt.jar" Doh. You can add

How can I list the available Cipher algorithms?

蓝咒 提交于 2019-11-27 04:01:37
问题 I am getting a Cipher implementation with Cipher.getInstance(String algorithm) . I am under the impression that the available algorithm names that I may pass differ based on what libraries which are present in my classpath. I would like to write a simple program that I can run with different classpaths that will list the available Cipher algorithm names. What method would I need to call to get this list? 回答1: Once I have a list of providers, as described in JB Nizet's post, I still don't have

Given final block not properly padded

不问归期 提交于 2019-11-26 11:14:12
I am trying to implement password based encryption algorithm, but I get this exception: javax.crypto.BadPaddingException: Given final block not properly padded What might be the problem? (I am new to Java.) Here is my code: public class PasswordCrypter { private Key key; public PasswordCrypter(String password) { try{ KeyGenerator generator; generator = KeyGenerator.getInstance("DES"); SecureRandom sec = new SecureRandom(password.getBytes()); generator.init(sec); key = generator.generateKey(); } catch (Exception e) { e.printStackTrace(); } } public byte[] encrypt(byte[] array) throws

Given final block not properly padded

被刻印的时光 ゝ 提交于 2019-11-26 03:29:51
问题 I am trying to implement password based encryption algorithm, but I get this exception: javax.crypto.BadPaddingException: Given final block not properly padded What might be the problem? (I am new to Java.) Here is my code: public class PasswordCrypter { private Key key; public PasswordCrypter(String password) { try{ KeyGenerator generator; generator = KeyGenerator.getInstance(\"DES\"); SecureRandom sec = new SecureRandom(password.getBytes()); generator.init(sec); key = generator.generateKey(