Package org.jasypt.util.binary

Examples of org.jasypt.util.binary.StrongBinaryEncryptor


    FileOutputStream fos = null;
    try {
      // Load binary data from a image file
      byte[] data = IOUtils.toByteArray(this.getClass().getResourceAsStream("/jasypt.png"));
      // Declare a strong encryptor
      StrongBinaryEncryptor be = new StrongBinaryEncryptor();
      // Set password to use
      be.setPassword(PASSWORD_FOR_ENCRYPTION);
      // Encrypt data. By default the algorithm used is
      // PBEWithMD5AndTripleDES
      byte[] encryptedData = be.encrypt(data);
      // Valid "encrypted" data
      byte[] decryptedData = be.decrypt(encryptedData);
      Assert.assertArrayEquals(data, decryptedData);
      // Create a image file with the decrypted data in order to validate
      // that data are not corrupted
      File f = File.createTempFile("JASYPT", ".png");
      fos = new FileOutputStream(f);
View Full Code Here

TOP

Related Classes of org.jasypt.util.binary.StrongBinaryEncryptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.