Class BlowfishCipher
- java.lang.Object
-
- org.silverpeas.core.security.encryption.cipher.BlowfishCipher
-
- All Implemented Interfaces:
Cipher
public class BlowfishCipher extends Object implements Cipher
Blowfish is a keyed, symmetric block cipher, designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. Blowfish provides a good encryption rate in software and no effective cryptanalysis of it has been found to date. However, the Advanced Encryption Standard now receives more attention.Blowfish was one of the first secure block ciphers not subject to any patents and therefore freely available for anyone to use. This benefit has contributed to its popularity in cryptographic software.
This implementation wraps the Blowfish cipher provided in the Java Cryptography API and it performs the redundant operations in the encryption and in the decryption.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BlowfishCipher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
decrypt(byte[] cipher, CipherKey keyCode)
Decrypt the specified code or cipher by using the specified cryptographic key.byte[]
encrypt(String data, CipherKey keyCode)
Encrypts the specified data by using the specified cryptographic key.CipherKey
generateCipherKey()
Generates randomly a cipher key that can be used in the encryption and in the decryption of data with this cipher.CryptographicAlgorithmName
getAlgorithmName()
Gets the name of the algorithm of the cipher.
-
-
-
Constructor Detail
-
BlowfishCipher
protected BlowfishCipher() throws NoSuchPaddingException, NoSuchAlgorithmException
-
-
Method Detail
-
getAlgorithmName
public CryptographicAlgorithmName getAlgorithmName()
Gets the name of the algorithm of the cipher.- Specified by:
getAlgorithmName
in interfaceCipher
- Returns:
- the algorithm name.
-
encrypt
public byte[] encrypt(String data, CipherKey keyCode) throws CryptoException
Description copied from interface:Cipher
Encrypts the specified data by using the specified cryptographic key.The String objects handled by the encryption is done according the UTF-8 charset.
- Specified by:
encrypt
in interfaceCipher
- Parameters:
data
- the data to encode.keyCode
- the key to use in the encryption.- Returns:
- the encrypted data in bytes.
- Throws:
CryptoException
- if an error has occurred in the data encryption.
-
decrypt
public String decrypt(byte[] cipher, CipherKey keyCode) throws CryptoException
Description copied from interface:Cipher
Decrypt the specified code or cipher by using the specified cryptographic key.The String objects handled by the encryption is done according the UTF-8 charset.
- Specified by:
decrypt
in interfaceCipher
- Parameters:
cipher
- the data in bytes encrypted by this cipher.keyCode
- the key to use in the decryption.- Returns:
- the decrypted data.
- Throws:
CryptoException
- if an error has occurred in the data decryption.
-
generateCipherKey
public CipherKey generateCipherKey() throws CryptoException
Description copied from interface:Cipher
Generates randomly a cipher key that can be used in the encryption and in the decryption of data with this cipher.- Specified by:
generateCipherKey
in interfaceCipher
- Returns:
- a computed key that can be used with this cipher in the encryption and in the decryption of data.
- Throws:
CryptoException
- if an error has occurred in the key generation.
-
-