com.cafesoft.core.crypto
Class SymmetricCipherUtils

java.lang.Object
  |
  +--com.cafesoft.core.crypto.SymmetricCipherUtils

public final class SymmetricCipherUtils
extends Object

SymmetricCipherUtils provides a number of useful methods for encrypting and decrypting various values using a SymmetricCipher.


Constructor Summary
SymmetricCipherUtils()
           
 
Method Summary
static String base64DecodeAndDecryptString(SymmetricCipher symCipher, String input)
          Base64 decode, then decrypt and return a String.
static String encryptAndBase64Encode(SymmetricCipher symCipher, byte[] input)
          Encrypt and Base64 encode an array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymmetricCipherUtils

public SymmetricCipherUtils()
Method Detail

encryptAndBase64Encode

public static final String encryptAndBase64Encode(SymmetricCipher symCipher,
                                                  byte[] input)
                                           throws IllegalStateException,
                                                  IllegalBlockSizeException,
                                                  BadPaddingException
Encrypt and Base64 encode an array of bytes.

The bytes in the input buffer are encrypted using the specified SymmetricCipher then returned as a Base64-encoded String.

Parameters:
symCipher - the SymmetricCipher to be used to encrypt the data.
input - the input byte buffer
Returns:
the encrypted, Base64 encoded value as a String.
Throws:
IllegalStateException - if this cipher is in a wrong state (e.g., has not been initialized)
IllegalBlockSizeException - - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size
BadPaddingException - if the internal encryption cipher has and invalid padding configuration or has an error while padding data.

base64DecodeAndDecryptString

public static final String base64DecodeAndDecryptString(SymmetricCipher symCipher,
                                                        String input)
                                                 throws IllegalStateException,
                                                        IllegalBlockSizeException,
                                                        BadPaddingException
Base64 decode, then decrypt and return a String.

The Base64-encoded String value is decoded, then decrypted and returned as a String value.

Parameters:
symCipher - the SymmetricCipher to be used to decrypt the data.
input - the Base64-encoded input String.
Returns:
the decoded, decrypted value as a String.
Throws:
IllegalStateException - if this cipher is in a wrong state (e.g., has not been initialized)
IllegalBlockSizeException - - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size
BadPaddingException - if the internal encryption cipher has and invalid padding configuration or has an error while padding data.


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.