intarsys runtime library

de.intarsys.tools.crypto
Class CryptoEnvironment

java.lang.Object
  extended by de.intarsys.tools.crypto.CryptoEnvironment

public class CryptoEnvironment
extends Object

A tool class for handling en/decryption


Method Summary
 byte[] decrypt(byte[] bytes)
          Decrypt a byte array which was previously encrypted using encrypt.
 String decryptEncoded(String value)
           
 String decryptEncoded(String value, ICryptdec cryptdec)
           
 String decryptRaw(String value)
          Decrypt a string which was previously encrypted using encrypt.
 byte[] encrypt(byte[] bytes)
          Encrypt a clear text array of bytes.
 String encryptEncoded(char[] value)
           
 String encryptEncoded(char[] value, ICryptdec cryptdec)
           
 String encryptEncoded(String value)
           
 String encryptEncoded(String value, ICryptdec cryptdec)
           
 String encryptRaw(String value)
          Encrypt a clear text array of chars.
static CryptoEnvironment get()
           
 ICryptdec getDefaultCryptdecDecrypt()
           
 ICryptdec getDefaultCryptdecEncrypt()
           
 ICryptdec lookupCryptdec(String id)
           
 void registerCryptdec(ICryptdec cryptdec)
           
 void setDefaultCryptdecDecrypt(ICryptdec defaultCryptdec)
           
 void setDefaultCryptdecEncrypt(ICryptdec defaultCryptdec)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static CryptoEnvironment get()

decrypt

public byte[] decrypt(byte[] bytes)
               throws IOException
Decrypt a byte array which was previously encrypted using encrypt. For decryption the default ICryptdec is used.

Parameters:
bytes -
Returns:
The decrypted representation of bytes
Throws:
IOException

decryptEncoded

public String decryptEncoded(String value)
                      throws IOException
Throws:
IOException

decryptEncoded

public String decryptEncoded(String value,
                             ICryptdec cryptdec)
                      throws IOException
Throws:
IOException

decryptRaw

public String decryptRaw(String value)
                  throws IOException
Decrypt a string which was previously encrypted using encrypt. Provided the same salt and passphrase are used for initialization, this method returns the original unencrypted input.

Parameters:
value -
Returns:
The decrypted representation of value
Throws:
IOException

encrypt

public byte[] encrypt(byte[] bytes)
               throws IOException
Encrypt a clear text array of bytes. The result is the plain encrypted byte array.

Parameters:
bytes -
Returns:
The encrypted representation of bytes
Throws:
IOException

encryptEncoded

public String encryptEncoded(char[] value)
                      throws IOException
Throws:
IOException

encryptEncoded

public String encryptEncoded(char[] value,
                             ICryptdec cryptdec)
                      throws IOException
Throws:
IOException

encryptEncoded

public String encryptEncoded(String value)
                      throws IOException
Throws:
IOException

encryptEncoded

public String encryptEncoded(String value,
                             ICryptdec cryptdec)
                      throws IOException
Throws:
IOException

encryptRaw

public String encryptRaw(String value)
                  throws IOException
Encrypt a clear text array of chars. The result is a Base64 encoded string version of the encrypted UTF-8 encoded input bytes.

Parameters:
value -
Returns:
An encrypted, invertible representation of value
Throws:
IOException

getDefaultCryptdecDecrypt

public ICryptdec getDefaultCryptdecDecrypt()

getDefaultCryptdecEncrypt

public ICryptdec getDefaultCryptdecEncrypt()

lookupCryptdec

public ICryptdec lookupCryptdec(String id)

registerCryptdec

public void registerCryptdec(ICryptdec cryptdec)

setDefaultCryptdecDecrypt

public void setDefaultCryptdecDecrypt(ICryptdec defaultCryptdec)

setDefaultCryptdecEncrypt

public void setDefaultCryptdecEncrypt(ICryptdec defaultCryptdec)

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.