Tuesday, September 16, 2014

Open SSL Commands

Utility commands to be used in Open SSL :

Steps to install Open SSL :

  • You need "Microsoft visual C++ 2008 Redistributable"
  • Open SSL setup for the server


Usage of Open SSL :

To generate a private key of length 2048 bits:
openssl genrsa -out private.pem 2048

To get it into the required (PKCS#8, DER) format:
openssl pkcs8 -topk8 -in private.pem -outform DER -out private.der -nocrypt

To generate a public key from the private key:
openssl rsa -in private.pem -pubout -outform DER -out public.der

An example of how to use the code:

FileEncryption secure = new FileEncryption();
//FileEncryption is a class defined which you can check in the link provided below

// to encrypt a file
secure.makeKey();
secure.saveKey(encryptedKeyFile, publicKeyFile);
secure.encrypt(fileToEncrypt, encryptedFile);

// to decrypt it again
secure.loadKey(encryptedKeyFile, privateKeyFile);
secure.decrypt(encryptedFile, unencryptedFile);


Source : http://www.macs.hw.ac.uk/~ml355/lore/pkencryption.htm

No comments:

Post a Comment