Class ByteArrayHandler


  • public class ByteArrayHandler
    extends java.lang.Object
    Simple routine to encrypt and decrypt using a passphrase. This service routine provides the basic PGP services between byte arrays. Note: this code plays no attention to -CONSOLE in the file name the specification of "_CONSOLE" in the filename. It also expects that a single pass phrase will have been used.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decrypt​(byte[] encrypted, char[] passPhrase)
      decrypt the passed in message stream
      static byte[] encrypt​(byte[] clearData, char[] passPhrase, java.lang.String fileName, int algorithm, boolean armor)
      Simple PGP encryptor between byte[].
      static void main​(java.lang.String[] args)  
      • Methods inherited from class java.lang.Object

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

      • ByteArrayHandler

        public ByteArrayHandler()
    • Method Detail

      • decrypt

        public static byte[] decrypt​(byte[] encrypted,
                                     char[] passPhrase)
                              throws java.io.IOException,
                                     PGPException,
                                     java.security.NoSuchProviderException
        decrypt the passed in message stream
        Parameters:
        encrypted - The message to be decrypted.
        passPhrase - Pass phrase (key)
        Returns:
        Clear text as a byte array. I18N considerations are not handled by this routine
        Throws:
        java.io.IOException
        PGPException
        java.security.NoSuchProviderException
      • encrypt

        public static byte[] encrypt​(byte[] clearData,
                                     char[] passPhrase,
                                     java.lang.String fileName,
                                     int algorithm,
                                     boolean armor)
                              throws java.io.IOException,
                                     PGPException,
                                     java.security.NoSuchProviderException
        Simple PGP encryptor between byte[].
        Parameters:
        clearData - The test to be encrypted
        passPhrase - The pass phrase (key). This method assumes that the key is a simple pass phrase, and does not yet support RSA or more sophisiticated keying.
        fileName - File name. This is used in the Literal Data Packet (tag 11) which is really inly important if the data is to be related to a file to be recovered later. Because this routine does not know the source of the information, the caller can set something here for file name use that will be carried. If this routine is being used to encrypt SOAP MIME bodies, for example, use the file name from the MIME type, if applicable. Or anything else appropriate.
        armor -
        Returns:
        encrypted data.
        Throws:
        java.io.IOException
        PGPException
        java.security.NoSuchProviderException
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception