Generate Aes Key Command Line

  

Run the madpwd3 utility to generate the encrypted password. The madpwd3 utility allows for the key and iv to be entered either from a file or directly on the command line. Use the -keyfile and -ivfile options to specify as a file or use the -key and -iv options to enter them at the command prompt. There is no limit on the length of the password.

  1. To use the Run as option, navigate to cmd.exe, usually in the System32 folder, and right-click its icon (or, if you use the command prompt often, as I do, create a shortcut to the program on your.
  2. Specifies the length of the data key. Use AES128 to generate a 128-bit symmetric key, or AES256 to generate a 256-bit symmetric key. You must specify either the KeySpec or the NumberOfBytes parameter (but not both) in every GenerateDataKey request. Possible values: AES256.

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

To decrypt:

Asymmetric encryption

Generate Aes Key Command Line

For Asymmetric encryption you must first generate your private key and extract the public key.

To encrypt:

To decrypt:

Encrypting files

You can't directly encrypt a large file using rsautl. Instead, do the following:

  • Generate a key using openssl rand, e.g. openssl rand 32 -out keyfile.
  • Encrypt the key file using openssl rsautl.
  • Encrypt the data using openssl enc, using the generated key from step 1.
  • Package the encrypted key file with the encrypted data. The recipient will need to decrypt the key with their private key, then decrypt the data with the resulting key.

Ultimate solution for safe and high secured encode anyone file in OpenSSL and command-line:

Private key generation (encrypted private key):

With unecrypted private key:

With encrypted private key:

With existing encrypted (unecrypted) private key:

Encrypt a file

Encrypt binary file:

Encrypt text file:

What is what:

  • smime — ssl command for S/MIME utility (smime(1)).
  • -encrypt — chosen method for file process.
  • -binary — use safe file process. Normally the input message is converted to 'canonical' format as required by the S/MIME specification, this switch disable it. It is necessary for all binary files (like a images, sounds, ZIP archives).
  • -aes-256-cbc — chosen cipher AES in 256 bit for encryption (strong). If not specified 40 bit RC2 is used (very weak). (Supported ciphers).
  • -in plainfile.zip — input file name.
  • -out encrypted.zip.enc — output file name.
  • -outform DER — encode output file as binary. If is not specified, file is encoded by base64 and file size will be increased by 30%.
  • yourSslCertificate.pem — file name of your certificate's. That should be in PEM format.

That command can very effectively a strongly encrypt any file regardless of its size or format.

Decrypt a file

Decrypt binary file:

For text files:

What is what:

  • -inform DER — same as -outform above.
  • -inkey private.key — file name of your private key. That should be in PEM format and can be encrypted by password.
  • -passin pass:your_password — (optional) your password for private key encrypt.

Verification

Creating a signed digest of a file:

Verify a signed digest:

Source


This article describes how to create and manage PGP Keys using PGP Command Line 8.x/9.x. This includes generating key pairs, importing and exporting keys, and sending keys to keyservers. This pertains to Windows NT4/2000/XP, Linux, and Unix platforms.
If you have PGP Desktop installed on the same Windows computer as the PGP Command Line, and you installed PGP Desktop to the default directory, then PGP Command Line will automatically locate and use your existing keyrings. If you are not using PGP Keyrings from a PGP Desktop product, you will need to create blank keyring files. To do so open a command prompt and type the following command:


This will create a pubring.pkr (public keyring) and secring.skr (private keyring) file in the default keyring location. For Windows this is in the My Documents>PGP folder. This article will use [ ] to identify information that you will need to enter that is specific to your individual keys.

Generate A Key Pair

To create a key pair using PGP Command Line follow these steps:

  1. Open a command shell or DOS prompt.
  2. On the command line, enter:
    NOTE: Any information that contains spaces must be contained inside quotation marks. See the example below step 3.
  3. Press 'Enter' when the command is complete. Example: The following example will show you how to create a 2048 Bit RSA key for Joe User, an employee of ACME Corp, with the passphrase 'my passphrase'.
    • Open a command prompt and enter the following:
    • Press 'Enter'
  4. PGP Command line will now generate your keypair. You should see your Key ID (i.e. 0X12345678), and a message that the key was successfully generated.

NOTE: To display your new keypair enter the following command:


This will display all the keys that are found on your keyring.

Export The Public Key

After the key pair is generated and identified, it is important to export the public portion (public key) of the key pair so others can import your public key and encrypt to you. NOTES: Once you have exported your public key to a file, it is easy to distribute. You can attach it to an email, paste the public key block text into the body of an email message (open with Notepad), or copy to a CD, for example. To export your public key you will need to have information about the key in order to identify it, which will be referred to in this document as (input). You can use the key ID (i.e. 0x12345678), user ID (i.e. 'Joe User'), or a portion of the user ID, (i.e. Joe). Display the keys To display the keys on your keyrings, open a command prompt and type the following:


Press Enter and the keys will be displayed. Make note of the key's username or number ID that you wish to export. Export the key: To export the key, do the following:

  1. Open a command prompt.
  2. From the command prompt, enter:
    NOTE: Remember that any information that contains spaces must be contained inside quotes.
  3. Press 'Enter' when the command is complete.

PGP Command Line responds by exporting keys as ASCII armor (.asc) files into the directory currently active on the command line. Example 1 The following example will show you how to export your public key using your key ID.

  • From the command prompt, enter:


Generate Aes Key Command Line Linux

  • Press 'Enter'.

Example 2 The following example will show you how to export your key using your user ID.

  • From the command prompt, enter:

Generate Aes 256 Key Command Line


  • Press 'Enter'.

Generate Aes Key Command Line Command

Import a PGP Key

You may import a public key from an ASCII Armor file (.asc) or from a text file, the process is the same for both. The file containing the key(s) to be imported must be in the current directory. As with exporting a key, this will be referred to as (input) in the examples. Both public and private keys will be imported if they exist in the file. If a key being imported already exists in the local keyring, the keys are merged. Import Key From File:

  1. Open a command prompt.
  2. From the command prompt, enter:
  3. Press 'Enter' when the command is complete.

Generate Aes Key Command Line Download

PGP Command Line responds as follows: Joe User.asc:import key {0:key imported as 0x12345678 Joe User} Example 1 The following example will show you how to import a key from an ASCII Armor file (.asc).

  • From the command prompt, enter:


  • Press 'Enter'.

Example 2 The following example will show you how to import a key from a text file containing the PGP key block.

  • From the command prompt, enter:

Generate Aes Key Command Line Commands


Openssl Command Line Generate Aes Key

  • Press 'Enter'.