rsa-asymmetric-cryptography-with-digital-signature

command
v0.0.0-...-a2a1f02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 10 Imported by: 0

README

rsa-asymmetric-cryptography-with-digital-signature example

Lets verify who the message is from. Create and verify a digital signature using the crypto/rsa standard package.

Refer to the crypto/rsa package for more info.

I added a digital signature to this example rsa-asymmetric-cryptography.

GitHub Webpage

OVERVIEW

RSA is a cryptosystem for public-key encryption, and is used for securing sensitive data over unsecured networks. It is also used to add digital signatures for verification.

This illustration may help,

IMAGE - rsa-asymmetric-cryptography-with-digital-signature.jpg - IMAGE

RUN

go run rsa-asymmetric-cryptography-with-digital-signature.go <FILENAME>
go run rsa-asymmetric-cryptography-with-digital-signature.go test.txt

HOW IT WORKS

Generate rsa keys,

// GENERATE PRIVATE & PUBLIC KEY PAIR
privateKeyRaw, err := rsa.GenerateKey(rand.Reader, 2048)

// EXTRACT PUBLIC KEY
publicKeyRaw := &privateKeyRaw.PublicKey

Create a digital signature,

// CREATE SIGNATURE
signatureByte, err := rsa.SignPSS(
    rand.Reader,
    senderPrivateKeyRaw,
    newhash,
    hashed,
    &opts,
)

Verify the digital signature,

// VERIFY SIGNATURE
err := rsa.VerifyPSS(
    senderPublicKeyRaw,
    newhash,
    hashed,
    signatureByte,
    &opts,
)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL