Class CipherHelper


  • public final class CipherHelper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      CipherHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decode​(java.lang.String encoded)  
      static java.lang.String decrypt​(byte[] ciphertext, javax.crypto.Cipher cipher)
      Decrypts the sealed message using the specified cipher.
      static java.lang.String decrypt​(byte[] ciphertext, javax.crypto.Cipher cipher, int blockSize)
      Decrypts the sealed message using the specified cipher.
      static java.lang.String encode​(byte[] data)  
      static byte[] encrypt​(java.lang.String text, javax.crypto.Cipher cipher)
      Encrypts the specified text using a given cipher.
      static byte[] encrypt​(java.lang.String text, javax.crypto.Cipher cipher, int blockSize)
      Encrypts the specified text using a given cipher.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CipherHelper

        public CipherHelper()
    • Method Detail

      • decrypt

        public static java.lang.String decrypt​(byte[] ciphertext,
                                               javax.crypto.Cipher cipher)
                                        throws java.io.IOException,
                                               java.security.GeneralSecurityException
        Decrypts the sealed message using the specified cipher.
        Parameters:
        ciphertext - the ciphertext to be decrypted
        cipher - the cipher to be used
        Returns:
        a decrypted text message
        Throws:
        java.io.IOException - if there was an error processing decryption
        java.security.GeneralSecurityException - if decryption fails
      • decrypt

        public static java.lang.String decrypt​(byte[] ciphertext,
                                               javax.crypto.Cipher cipher,
                                               int blockSize)
                                        throws java.io.IOException,
                                               java.security.GeneralSecurityException
        Decrypts the sealed message using the specified cipher.
        Parameters:
        ciphertext - the ciphertext to be decrypted
        cipher - the cipher to be used
        blockSize - the block size
        Returns:
        a decrypted text message
        Throws:
        java.io.IOException - if there was an error processing decryption
        java.security.GeneralSecurityException - if decryption fails
      • encrypt

        public static byte[] encrypt​(java.lang.String text,
                                     javax.crypto.Cipher cipher)
                              throws java.io.IOException,
                                     java.security.GeneralSecurityException
        Encrypts the specified text using a given cipher.
        Parameters:
        text - the text to be decrypted
        cipher - the cipher to be used
        Returns:
        ciphertext
        Throws:
        java.io.IOException - if there was an error during encryption
        java.security.GeneralSecurityException - if encryption fails
      • encrypt

        public static byte[] encrypt​(java.lang.String text,
                                     javax.crypto.Cipher cipher,
                                     int blockSize)
                              throws java.io.IOException,
                                     java.security.GeneralSecurityException
        Encrypts the specified text using a given cipher.
        Parameters:
        text - the text to be decrypted
        cipher - the cipher to be used
        blockSize - the blockSize
        Returns:
        ciphertext
        Throws:
        java.io.IOException - if there was an error during encryption
        java.security.GeneralSecurityException - if encryption fails
      • encode

        public static java.lang.String encode​(byte[] data)
      • decode

        public static byte[] decode​(java.lang.String encoded)