현재 내가 사용중인 라이브러리에서 사용가능한 알고리즘 목록을 출력할 수 있다. 

 

버전을 올린다던지 알고리즘 변경할때 사용하면 좋을 것 같다. 

 

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentPBEConfig;
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
import org.jasypt.registry.AlgorithmRegistry;


for (Object algorithm : AlgorithmRegistry.getAllPBEAlgorithms()) {
  try { 
    StandardPBEStringEncryptor encryptor2 = new StandardPBEStringEncryptor(); 
    encryptor2.setPassword("somePassword"); 
    encryptor2.setAlgorithm(String.valueOf(algorithm)); 
    String str = "test"; 
    String encStr = encryptor2.encrypt(str); 
    String decStr = encryptor2.decrypt(encStr); 

  	System.out.println("supported :::: " +algorithm);
  } catch (EncryptionOperationNotPossibleException e) {

  	System.out.println("unsupported :::: " + algorithm);
  } 
}

+ Recent posts