Giter Site home page Giter Site logo

gpg's Introduction

GPG


This repository demonstrates the use of GPG.

We'll simulate 2 parties: bob and alice. Every time you perform actions as one of them, you need to set the GNUPGHOME enviroment variable to their directory.

Bob and Alice Simulation

We'll do a simulation in which we have 2 persons: Bob and Alice. In this simulation, Alice sends an encrypted message to Bob.

Generate a key pair

We'll start working with bob.

$ export GNUPGHOME=$PWD/bob
$ gpg --full-generate-key

Answer the questions. For email, write [email protected] After this, you'll see that the bob directory is filled with some files. This is bob's private key, plus some other stuff.

Export Bob's public key

Now we want to export Bob's public key so that Alice can import it.

$ gpg --output bob.key --export [email protected]

Import Bob's public key


Now, as Alice, let's import Bob's public key.

$ export GNUPGHOME=$PWD/alice
$ gpg --import bob.key

Encrypt a message

Now, as Alice, let's encrypt a message with Bob's public key:

$ gpg --encrypt -r [email protected] message.txt

This will generate a message.txt.gpg file, which is the encrypted message. The -r stands for receipient, and it tells gpg with what public key to encrypt the message.

Decrypt

Now, as Bob, let's decrypt the message:

$ gpg -d message.txt.gpg

Sign a message

Now let's do this again, this time, in addition to encrypting the message, we want to sign it as Alice, so that Bob can be sure that Alice is the one that sent this message.

First, as Alice, generate a key-pair, as we've done with Bob. Then, import that public key with Bob, as we've done with Alice.

Now, encrypt the message as such:

$ gpg --encrypt --sign -r [email protected] message.txt

Decryption is done the same.

gpg's People

Contributors

yoav-klein avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.