Public and Private Key

For cryptographically secure messaging, a key pair is generated for each identity.

The Public as the name suggest is the key visible to all parties in the communication network; the private key is the secret key only known to the individual.

Here is a simulation using R. [Again you don't have to know R; just read the text step-by-step explanations]

Here is an example where Bob sends a message to Alice through an insecure communication channel. They use Asymmetric key cryptography (Public Private Key pair).

Bob has a Key pair. A public key visible to everyone and a private key which he uses to decipher received messages.

> bob_key <- keygen()
> bob_pubkey <- pubkey(bob_key)

Alice has a Key pair. A public key visible to everyone and a private key which she uses to decipher received messages.

> alice_key <- keygen()
> alice_pubkey <- pubkey(alice_key)

Bob sends an encrypted message to Alice since he can't trust the communication channel. For encrypting, he uses Alice's public key.

> msg <- charToRaw("This is the message from Bob to Alice")
> ciphertext <- auth_encrypt(msg, bob_key, alice_pubkey)

Alice receives this message (ciphertext). Only she can decrypt this message as it has been encrypted using her Public key (alice_pubkey)

> orig <- auth_decrypt(ciphertext, alice_key, bob_pubkey)
# orig is in RAW format. Covert Raw to Char to see the message in plain text.
> rawToChar(orig)

results matching ""

    No results matching ""