Blowfish Secret Key Encryption Tests

This section provides the test result of Blowfish secret key encryption and decryption using the javax.crypto.Cipher class.

Here is the result of my first test of JceSecretCipher.java with the Blowfish algorithm. The Blowfish key can be generated from JceSecretKeyTest.java.

Here is the encryption step:

herong> java JceSecretKeyTest 56 bfish Blowfish

herong> javac JceSecretCipher.java

herong> java JceSecretCipher Blowfish encrypt bfish.key \
   JceSecretCipher.java jce.cph

KeySpec Object Info:
Saved File = bfish.key
Length = 7
toString = javax.crypto.spec.SecretKeySpec@2685016e

SecretKey Object Info:
Algorithm = Blowfish
toString = javax.crypto.spec.SecretKeySpec@2685016e

Cipher Object Info:
Block Size = 8
Algorithm = Blowfish
Provider = SunJCE version 1.6
toString = javax.crypto.Cipher@b179c3

Cipher Process Info:
Input Size = 3684
Output Size = 3688

Here is the decryption step:

herong> java JceSecretCipher Blowfish decrypt bfish.key jce.cph jce.clr

KeySpec Object Info:
Saved File = bfish.key
Length = 7
toString = javax.crypto.spec.SecretKeySpec@2685016e

SecretKey Object Info:
Algorithm = Blowfish
toString = javax.crypto.spec.SecretKeySpec@2685016e

Cipher Object Info:
Block Size = 8
Algorithm = Blowfish
Provider = SunJCE version 1.6
toString = javax.crypto.Cipher@b179c3

Cipher Process Info:
Input Size = 3688
Output Size = 3684

Now checking the decryption output with the original text:

herong> comp JceSecretCipher.java jce.clr

Comparing JceSecretCipher.java and jce.clr...
Files compare OK

Note that:

You can do more tests with DES and HmacMD5 keys.

Table of Contents

 About This Book

 Cryptography Terminology

 Cryptography Basic Concepts

 Introduction to AES (Advanced Encryption Standard)

 Introduction to DES Algorithm

 DES Algorithm - Illustrated with Java Programs

 DES Algorithm Java Implementation

 DES Algorithm - Java Implementation in JDK JCE

 DES Encryption Operation Modes

 DES in Stream Cipher Modes

 PHP Implementation of DES - mcrypt

 Blowfish - 8-Byte Block Cipher

 Secret Key Generation and Management

Cipher - Secret Key Encryption and Decryption

 javax.crypto.Cipher - The Secret Key Encryption Class

 JceSecretCipher.java - Secret Key Encryption Sample Program

Blowfish Secret Key Encryption Tests

 Introduction of RSA Algorithm

 RSA Implementation using java.math.BigInteger Class

 Introduction of DSA (Digital Signature Algorithm)

 Java Default Implementation of DSA

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Cipher - Public Key Encryption and Decryption

 MD5 Mesasge Digest Algorithm

 SHA1 Mesasge Digest Algorithm

 OpenSSL Introduction and Installation

 OpenSSL Generating and Managing RSA Keys

 OpenSSL Managing Certificates

 OpenSSL Generating and Signing CSR

 OpenSSL Validating Certificate Path

 "keytool" and "keystore" from JDK

 "OpenSSL" Signing CSR Generated by "keytool"

 Migrating Keys from "keystore" to "OpenSSL" Key Files

 Certificate X.509 Standard and DER/PEM Formats

 Migrating Keys from "OpenSSL" Key Files to "keystore"

 Using Certificates in IE

 Using Certificates in Google Chrome

 Using Certificates in Firefox

 Archived Tutorials

 References

 Full Version in PDF/EPUB