// GenerateKey.java

import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;

public class GenerateKey
{
  static public void main( String args[] ) throws Exception {
    String keyFilename = args[0];
    String algorithm = "DES";

    // Generate the key
    SecureRandom sr = new SecureRandom();
    KeyGenerator kg = KeyGenerator.getInstance( algorithm );
    kg.init( sr );
    SecretKey key = kg.generateKey();

    // Save the raw key bytes in a file
    Util.writeFile( keyFilename, key.getEncoded() );
  }
}