1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| import com.ulisesbocchio.jasyptspringboot.encryptor.SimpleAsymmetricConfig; import com.ulisesbocchio.jasyptspringboot.encryptor.SimpleAsymmetricStringEncryptor; import org.jasypt.encryption.StringEncryptor;
SimpleAsymmetricConfig config = new SimpleAsymmetricConfig(); config.setKeyFormat(PEM); config.setPublicKey("-----BEGIN PUBLIC KEY-----\n" + "******\n" + "-----END PUBLIC KEY-----\n"); config.setPrivateKey("-----BEGIN PRIVATE KEY-----\n" + "******\n" + "-----END PRIVATE KEY-----\n"); StringEncryptor encryptor = new SimpleAsymmetricStringEncryptor(config); String message = "passord"; String encrypted = encryptor.encrypt(message); System.out.printf("Encrypted message %s\n", encrypted); System.out.printf("Decrypted message %s\n", encryptor.decrypt(encrypted));
|