Cryptography Tutorials - Herong's Tutorial Examples - v5.42, by Herong Yang
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
Introduction to AES (Advanced Encryption Standard)
DES Algorithm - Illustrated with Java Programs
DES Algorithm Java Implementation
DES Algorithm - Java Implementation in JDK JCE
DES Encryption Operation 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
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
OpenSSL Introduction and Installation
OpenSSL Generating and Managing RSA Keys
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"