<CFCONTENT TYPE="text/vnd.wap.wml"><?xml version="1.0"?>
  // Encrypting Raw Data Using a Key

    // The DES algorithm requires a trusted source of random bits
    SecureRandom sr = new SecureRandom();

    byte rawKeyData[] = /* get the raw key data from somewhere */;

    // Create a DES key object specification from the raw data
    DESKeySpec dks = new DESKeySpec( rawKeyData );

    // Create a key factory and use it to turn the DESKeySpec into
    // a SecretKey object
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance( "DES" );
    SecretKey key = keyFactory.generateSecret( dks );

    // The Cipher object does the actual encryption
    Cipher cipher = Cipher.getInstance( "DES" );

    // Initialize the cipher with the key
    cipher.init( Cipher.ENCRYPT_MODE, key, sr );

    // Now we'll grab our data and encrypt it
    byte data[] = /* get from somewhere */

    // The actual encryption step
    byte encryptedData[] = cipher.doFinal( data );

    // Do something with the encrypted data
    doSomething( encryptedData );