Project Wonder 5.0.0.8654

er.extensions.crypting
Class ERXCrypto

java.lang.Object
  extended by er.extensions.crypting.ERXCrypto

public class ERXCrypto
extends Object

Provides a wrapper around common encryption and decryption operations. ERXCrypto provides built-in support for DES and Blowfish crypters. You can use the "er.extensions.ERXCrypto.crypters" property to override or provide your own. If you only want DES and/or Blowfish, you don't need to set crypters yourself.

Author:
?

Field Summary
static String BLOWFISH
          The constant for the Blowfish encryption algorithm.
static String DES
          The constant for the DES encryption algorithm.
static Logger log
          logging support
 
Constructor Summary
ERXCrypto()
           
 
Method Summary
static byte[] base64Decode(String s)
          Base64 decodes the passed in String
static String base64Encode(byte[] byteArray)
          Base64 encodes the passed in byte[]
static String base64EncryptedString(String clearText)
          Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)
static String base64EncryptedString(String clearText, Key secretKey)
          Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)
static String base64HashedString(String v)
          Uses the SHA hash algorithm found in the Sun JCE to hash the passed in String.
static String blowfishDecode(String encryptedText)
          Deprecated. use ERXBlowfishCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.BLOWFISH)
static String blowfishEncode(String clearText)
          Deprecated. use ERXBlowfishCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.BLOWFISH)
static String bytesToString(byte[] bytes)
          Deprecated. use ERXStringUtilities.byteArrayToHexString instead.
static ERXCrypterInterface crypterForAlgorithm(String algorithm)
          Returns the crypter for the given algorithm.
static NSMutableDictionary<String,String> decodedFormValuesDictionary(NSDictionary<String,NSArray<String>> dict)
          Decodes all of the values from a given dictionary using the default crypter.
static String decryptedBase64String(String encryptedText)
          Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)
static String decryptedBase64String(String encryptedText, Key secretKey)
          Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)
static ERXCrypterInterface defaultCrypter()
          Returns the default crypter.
static void main(String[] args)
          Run this with ERXMainRunner passing in the plaintext you want to encrypt using the default crypter.
static void setCrypterForAlgorithm(ERXCrypterInterface crypter, String algorithm)
          Sets the crypter for the given algorithm.
static void setSecretKeyPath(String secretKeyPath)
          Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)
static void setSecretKeyPathFramework(String secretKeyPathFramework)
          Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)
static String shaEncode(String text)
          Sha encodes a given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final Logger log
logging support


DES

public static final String DES
The constant for the DES encryption algorithm.

See Also:
Constant Field Values

BLOWFISH

public static final String BLOWFISH
The constant for the Blowfish encryption algorithm.

See Also:
Constant Field Values
Constructor Detail

ERXCrypto

public ERXCrypto()
Method Detail

defaultCrypter

public static ERXCrypterInterface defaultCrypter()
Returns the default crypter. By default this is Blowfish, but you can override the choice by setting er.extensions.ERXCrypto.default.

Returns:
the default crypter

setCrypterForAlgorithm

public static void setCrypterForAlgorithm(ERXCrypterInterface crypter,
                                          String algorithm)
Sets the crypter for the given algorithm.

Parameters:
crypter - the crypter to use
algorithm - the algorithm name

crypterForAlgorithm

public static ERXCrypterInterface crypterForAlgorithm(String algorithm)
Returns the crypter for the given algorithm. By default, DES and Blowfish are available ("DES", "Blowfish", etc).

Parameters:
algorithm - the algorithm to lookup
Returns:
the corresponding crypter
Throws:
IllegalArgumentException - if there is no crypter for the given algorithm

decodedFormValuesDictionary

public static NSMutableDictionary<String,String> decodedFormValuesDictionary(NSDictionary<String,NSArray<String>> dict)
Decodes all of the values from a given dictionary using the default crypter.

Parameters:
dict - dictionary of key value pairs where the values are encoded strings
Returns:
a dictionary of decoded key-value pairs

base64HashedString

public static String base64HashedString(String v)
Uses the SHA hash algorithm found in the Sun JCE to hash the passed in String. This String is then base64 encoded and returned.


shaEncode

public static String shaEncode(String text)
Sha encodes a given string. The resulting string is safe to use in urls and cookies. From the digest of the string it is nearly impossible to determine what the original string was. Running the same string through the Sha digest multiple times will always produce the same hash.

Parameters:
text - to be put through the sha digest
Returns:
hashed form of the given string

base64Encode

public static String base64Encode(byte[] byteArray)
Base64 encodes the passed in byte[]


base64Decode

public static byte[] base64Decode(String s)
                           throws IOException
Base64 decodes the passed in String

Throws:
IOException

bytesToString

@Deprecated
public static String bytesToString(byte[] bytes)
Deprecated. use ERXStringUtilities.byteArrayToHexString instead.


base64EncryptedString

@Deprecated
public static String base64EncryptedString(String clearText)
Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)


base64EncryptedString

@Deprecated
public static String base64EncryptedString(String clearText,
                                                      Key secretKey)
Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)


decryptedBase64String

@Deprecated
public static String decryptedBase64String(String encryptedText)
Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)


decryptedBase64String

@Deprecated
public static String decryptedBase64String(String encryptedText,
                                                      Key secretKey)
Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)


blowfishEncode

@Deprecated
public static String blowfishEncode(String clearText)
Deprecated. use ERXBlowfishCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.BLOWFISH)


blowfishDecode

@Deprecated
public static String blowfishDecode(String encryptedText)
Deprecated. use ERXBlowfishCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.BLOWFISH)


setSecretKeyPathFramework

@Deprecated
public static void setSecretKeyPathFramework(String secretKeyPathFramework)
Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)


setSecretKeyPath

@Deprecated
public static void setSecretKeyPath(String secretKeyPath)
Deprecated. use ERXDESCrypter and/or ERXCrypto.crypterForAlgorithm(ERXCrypto.DES)


main

public static void main(String[] args)
Run this with ERXMainRunner passing in the plaintext you want to encrypt using the default crypter. This is useful if you are using encrypted properties and you need a quick way to know what to set the property value to.

Parameters:
args - the plaintext to encrypt

Last updated: Thu, Nov 20, 2008 • 04:36 AM EST

Copyright © 2002 – 2007 Project Wonder.