Package org.jitterbit.util.crypto

Examples of org.jitterbit.util.crypto.DefaultPBEStringCryptographer


     * @throws ServerCryptoException
     *             if an error occurs
     */
    public static String encryptString(String plainText, String passPhrase) throws ServerCryptoException {
        try {
            PBEStringCryptographer crypto = new DefaultPBEStringCryptographer(salt, 1);
            crypto.setAlgorithm(algorithm);
            crypto.setPassphrase(passPhrase);
            byte[] encrypted = crypto.encrypt(plainText);
            Base64 base64 = new Base64();
            return new String(base64.encode(encrypted));
        } catch (StringCryptographerException ex) {
            throw new ServerCryptoException(ex);
        } catch (StringEncryptionException ex) {
View Full Code Here


     * @throws ServerCryptoException
     *             if an error occurs, for example if the wrong pass phrase is used
     */
    public static String decryptString(String encrypted, String passPhrase) throws ServerCryptoException {
        try {
            PBEStringCryptographer crypto = new DefaultPBEStringCryptographer(salt, 1);
            crypto.setAlgorithm(algorithm);
            crypto.setPassphrase(passPhrase);
            Base64 base64 = new Base64();
            byte[] bytes = base64.decode(encrypted.getBytes());
            return crypto.decrypt(bytes);
        } catch (StringCryptographerException ex) {
            throw new ServerCryptoException(ex);
        } catch (StringDecrypterException ex) {
            throw new ServerCryptoException(ex);
        }
View Full Code Here

TOP

Related Classes of org.jitterbit.util.crypto.DefaultPBEStringCryptographer

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.