crypt

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(password, data []byte) ([]byte, error)

func AESEncrypt

func AESEncrypt(password []byte, data []byte) ([]byte, error)

func PGPDecryptAndVerifyMessage

func PGPDecryptAndVerifyMessage(privateKey *crypto.Key, publicKey *crypto.Key, message []byte) ([]byte, error)

func PGPEncryptAndSignMessage

func PGPEncryptAndSignMessage(privateKey *crypto.Key, publicKey *crypto.Key, message []byte) ([]byte, error)

func PGPGenerateKeyPair

func PGPGenerateKeyPair(accountName string) (*crypto.Key, error)

func PGPPrivateKeyToBytes

func PGPPrivateKeyToBytes(key *crypto.Key, password string) ([]byte, error)

func PGPPrivateKeyToMem

func PGPPrivateKeyToMem(privateBytes []byte, password string) (*crypto.Key, error)

func PGPPublicKeyToBytes

func PGPPublicKeyToBytes(key *crypto.Key) ([]byte, error)

func PGPPublicKeyToMem

func PGPPublicKeyToMem(publicBytes []byte) (*crypto.Key, error)

func PackMessage

func PackMessage(message []byte, signature []byte, pubkey []byte) (string, error)

func RSADecryptAndVerifyMessage

func RSADecryptAndVerifyMessage(receiverPrivateKey *rsa.PrivateKey, senderPublicKey *rsa.PublicKey, message []byte, signature []byte) ([]byte, error)

Decrypts and verifies the message using the recipient's private key and sender's public key. Returns the decrypted message on success and an error otherwise.

func RSAEncryptAndSignMessage

func RSAEncryptAndSignMessage(senderPrivateKey *rsa.PrivateKey, recipientPublicKey *rsa.PublicKey, message []byte) ([]byte, []byte, error)

Encrypts and signs the message using the sender's private key and recipient's public key. Returns the encrypted message on success and an error otherwise.

func RSAGenerateKeyPair

func RSAGenerateKeyPair(size int) (*rsa.PrivateKey, *rsa.PublicKey, error)

Generates a new RSA Key Pair and returns them as pointers.

func RSAPrivateKeyToBytes

func RSAPrivateKeyToBytes(privateKey *rsa.PrivateKey, password string) ([]byte, error)

Converts a Private Key to a PEM encoded byte array.

func RSAPrivateKeyToMem

func RSAPrivateKeyToMem(privateKeyBytes []byte, password string) (*rsa.PrivateKey, error)

Converts a PEM encoded byte array to a Private Key Pointer.

func RSAPublicKeyToBytes

func RSAPublicKeyToBytes(publicKey *rsa.PublicKey) ([]byte, error)

Converts a Public Key to a PEM encoded byte array.

func RSAPublicKeyToMem

func RSAPublicKeyToMem(publicKeyPEM []byte) (*rsa.PublicKey, error)

Converts a PEM encoded byte array to a Public Key Pointer.

func UnpackMessage

func UnpackMessage(message string) ([]byte, []byte, []byte, error)

Types

type MessageWrapper

type MessageWrapper struct {
	Message   []byte `json:"message"`
	Signature []byte `json:"signature"`
	Pubkey    []byte `json:"pubkey"`
}

Jump to

Keyboard shortcuts

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