Share the post "The Inspiration Behind The Logo Design Of Google Chrome"
Haha! This is one funny strip. Kudos to the artist.

In my previous post (Encrypt Using Blowflish And Java), I talked about a way to encrypt using Blowfish in Java. To decrypt it back to its original string, use this method below. Again, part of this method’s code uses a secondary method that converts hexadecimal to binary. You can find it here.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public static String decrypt(String key, String cipher) { Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 3); String plain = null; byte[] cipherText = convertHexadecimal2Binary(cipher.getBytes()); try { SecretKeySpec blowfishKey = new SecretKeySpec(key.getBytes(), "Blowfish"); Cipher blowfishCipher = Cipher.getInstance("Blowfish", "BC"); blowfishCipher.init(Cipher.DECRYPT_MODE, (Key)blowfishKey); byte[] plainText = blowfishCipher.doFinal(cipherText); plain = new String(plainText); } catch (Exception e) { e.printStackTrace(); } return plain; } |
Blowfish is a symmetric block cipher that can be used as a drop-in replacement for DES or IDEA. It takes a variable-length key, from 32 bits to 448 bits, making it an ideal way for encryption purposes. Java supports Blowflish encryption in its API. Here is a method that will encrypt using Blowfish. Part of the code converts the string to be encrypted to byte[] array so this method uses a secondary method called convertBinary2Hexadecimal() which you can find here.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public static String encrypt(String key, String plain) { Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 3); byte[] plainText = plain.getBytes(); String cipher = null; try { SecretKeySpec blowfishKey = new SecretKeySpec(key.getBytes(), "Blowfish"); Cipher blowfishCipher = Cipher.getInstance("Blowfish", "BC"); blowfishCipher.init(Cipher.ENCRYPT_MODE, (Key)blowfishKey); byte[] cipherText = blowfishCipher.doFinal(plainText); cipher = convertBinary2Hexadecimal(cipherText); } catch (Exception e) { e.printStackTrace(); } return cipher; } |