Class 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.
    • Method Detail

      • 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 interface Cipher
        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 interface Cipher
        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 interface Cipher
        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.