나는 DB의 비밀번호 저장을 PBKDF2
생성 된 해시로 지정하는 Java 인증 하위 시스템에서 작업 중이며, 이제 SHA1
또는 SHA512
을 PFR로 사용해야할지 결정하려고합니다. 나는 두 가지 스펙을 모두 살펴 보았지만, 나는 수학적으로 집중적으로 따라야했다. PBKDF2WithHmacSHA512
이 PBKDF2WithHmacSHA1
과 다른 점을 암호 해독력이 더 좋은 사람이 설명 할 수 있습니까?PBKDF2WithHmacSHA512 VSs. PBKDF2WithHmacSHA1
는 여기에 내가 할 노력하고있어 무엇 :
private static final int HASH_BYTE_SIZE = 64; // 512 bits
private static final int PBKDF2_ITERATIONS = 1000;
// generate random salt
SecureRandom random = new SecureRandom();
byte salt[] = new byte[SALT_BYTE_SIZE]; // use salt size at least as long as hash
random.nextBytes(salt);
// generate Hash
PBEKeySpec spec = new PBEKeySpec(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); // we would like this to be "PBKDF2WithHmacSHA512" instead? What Provider implements it?
byte[] hash = skf.generateSecret(spec).getEncoded();
// convert hash and salt to hex and store in DB as CHAR(64)...
오른쪽 속도는 중요합니다. 그러나 PBKDF2에는 조정 가능한 작업 요소가 포함되어 있습니다. 따라서 SHA512 대 SHA1의 상대 속도는 무의미합니다. –