All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vfdtech.interfaces.IEncryptDecryptUtil Maven / Gradle / Ivy

Go to download

A utilities service with generic tools implementation. Can be plugged into your java project

There is a newer version: 0.3.5
Show newest version
package org.vfdtech.interfaces;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author Muhammed.Ibrahim
 */
public interface IEncryptDecryptUtil {
    
    /**
     * This method encrypts plain data using PGP encryption mode
     * 
     * @param plainData String      Plain data to be encrypted
     * @param publicKey InputStream Public key required for encryption
     * @return          String      Encrypted data
     * @throws Exception 
     */
    public String pgpEncrypt(final String plainData, final InputStream publicKey) throws Exception;
    
    /**
     * This method encrypts plain data using PGP encryption mode
     * 
     * @param plainData String  Plain data to be encrypted
     * @param publicKey String  Public key required for encryption
     * @return          String  Encrypted data
     * @throws Exception 
     */
    public String pgpEncrypt(final String plainData, final String publicKey) throws Exception;
    
    /**
     * This method encrypts plain data using PGP encryption mode
     * 
     * @param plainData Object  Plain data to be encrypted
     * @param publicKey String  Public key required for encryption
     * @return          String  Encrypted data
     * @throws Exception 
     */
    public String pgpEncrypt(final Object plainData, final String publicKey) throws Exception;
    
    /**
     * This method decrypts encrypted data using PGP encryption mode
     * 
     * @param encryptedData
     * @param privateKeyIn
     * @param keyPassCode
     * @return
     * @throws Exception 
     */
    public String pgpDecrypt(final String encryptedData, final InputStream privateKeyIn, final String keyPassCode) throws Exception;
    
    /**
     * This method decrypts encrypted data using PGP encryption mode
     * 
     * @param encryptedData
     * @param privateKey
     * @param keyPassCode
     * @return
     * @throws Exception 
     */
    public String pgpDecrypt(final String encryptedData, final String privateKey, final String keyPassCode) throws Exception;
    
    /**
     * This method decrypts encrypted data using PGP encryption mode and returns Pojo object of type
     * 
     * @param 
     * @param encryptedData
     * @param privateKeyIn
     * @param keyPassCode
     * @param type
     * @return
     * @throws Exception 
     */
    public  T pgpDecrypt(final String encryptedData, final InputStream privateKeyIn, final String keyPassCode, Class type) throws Exception;
    
    /**
     * This method decrypts encrypted data using PGP encryption mode and returns Pojo object of type
     * 
     * @param 
     * @param encryptedData
     * @param privateKey
     * @param keyPassCode
     * @param type
     * @return
     * @throws Exception 
     */
    public  T pgpDecrypt(final String encryptedData, final String privateKey, final String keyPassCode, Class type) throws Exception;
    
    /**
     * This method encrypts plain data using AES PKCS5Padding encryption algorithm
     * 
     * @param plainData
     * @param key
     * @return
     * @throws Exception 
     */
    public String aesEncrypt(final String plainData, final String key) throws Exception;

    String aesEncrypt(String plain, String secretKey, String iv) throws NoSuchAlgorithmException,
            NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException;

    /**
     * This method encrypts plain data using AES PKCS5Padding encryption algorithm
     * 
     * @param plainData
     * @param key
     * @return
     * @throws Exception 
     */
    public String aesEncrypt(final Object plainData, final String key) throws Exception;
    
    /**
     * This method decrypts plain data using AES PKCS5Padding encryption algorithm
     * 
     * @param encryptedData
     * @param key
     * @return
     * @throws Exception 
     */
    public String aesDecrypt(final String encryptedData, final String key) throws Exception;
    
    /**
     * This method decrypts plain data using AES PKCS5Padding encryption algorithm and returns Pojo object of type
     * 
     * @param 
     * @param encryptedData
     * @param key
     * @param type
     * @return
     * @throws Exception 
     */
    public  T aesDecrypt(final String encryptedData, final String key, Class type) throws Exception;
    /**
     * This method decrypts nip data
     *
     * @param encryptedData
     * @return String
     */
    public String nipDecrypt(final String encryptedData);
    /**
     * This method decrypts nip data
     *
     * @param plainData
     * @return String
     */
    public String nipEncrypt(final String plainData);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy