Simple command line encryption and decryption with gpg
Secret and public key rings are in working directory.
Encrypt
>gpg.exe -e -r mb-pets@bce.tni --keyring pubring.gpg encryptme.txtUse this key anyway?yes
//output called encryptme.txt.gpg
Including private key prevents question about trusting public key.
>gpg.exe -e -r mb-pets@bce.int --homedir . --keyring .\pubring.gpg --secret-keyring secring.gpg encryptme.txt//output called encryptme.txt.gpg
Output encrpyte file as base64 text.
gpg.exe -e -a -r mb-pets@bce.int --homedir . --keyring pubring.gpg --secret-keyring secring.gpg encryptme.txt//output called encryptme.txt.asc
//With verbose
>gpg.exe -e -a -r mb-step@ecb.int --homedir . --verbose --keyring pubring.gpg --secret-keyring secring.gpg encryptme.txt
gpg: using secondary key 57D35DF1 instead of primary key 23E858FE
gpg: This key belongs to us
gpg: reading from `.\encryptme.txt'
gpg: writing to `.\encryptme.txt.asc'
gpg: ELG-E/AES256 encrypted for: "57D35DF1 Statistics STEP Transfer (STEP Mail 1) <mb-step@ecb.int>"
It's also possbile base64 using openssl; I think.
/usr/sfw/bin/openssl enc -base64 -in signme.txt.gpg -out signme.txt.b64
An attemp to base64 with powershall looked like this; however, beware because this wasn't tested properly.
[System.Convert]::ToBase64String(([System.Text.Encoding]::UTF8.GetBytes((get-content ".\signme.txt.gpg")))); set-content (".\signme.txt.asc" );
To unbase 64 it:
[System.Convert]::FromBase64String((get-content ".\signme.txt.asc")); set-content (".\out.gpg" );
Decrypt
>gpg.exe --homedir . --decrypt --secret-keyring .\secring.gpg --keyring .\pubring.gpg .\secret.txt.gpgYou need a passphrase to unlock the secret key for **********
No comments:
Post a Comment