Generate a Blowfish key : Blowfish « Security « Java Tutorial

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class MainClass {

  public static void main(String[] args) throws Exception {

    KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
    SecretKey key = keyGenerator.generateKey();

    Cipher cipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding");
    cipher.init(Cipher.ENCRYPT_MODE, key);
    byte[] cipherText = cipher.doFinal("This is a test.".getBytes("UTF8"));
    System.out.println(new String(cipherText));

36.5.1.Generate a Blowfish key
36.5.2.Create a Blowfish key, encrypts some text,prints the ciphertext, then decrypts the text
36.5.3.A Blowfish example