crypto

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptWithRSA

func DecryptWithRSA(privateKey *rsa.PrivateKey, ciphertext []byte, label []byte) ([]byte, error)

DecryptWithRSA decrypts data using RSA-OAEP with SHA256

func EncodePrivateKeyToPEM

func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) []byte

EncodePrivateKeyToPEM converts an RSA private key to PEM format using PKCS#8

func EncodePublicKeyToPEM

func EncodePublicKeyToPEM(publicKey *rsa.PublicKey) []byte

EncodePublicKeyToPEM converts an RSA public key to PEM format using PKIX

func EncryptWithRSA

func EncryptWithRSA(publicKey *rsa.PublicKey, data []byte, label []byte) ([]byte, error)

EncryptWithRSA encrypts data using RSA-OAEP with SHA256

func GenerateRSAKeyPair

func GenerateRSAKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateRSAKeyPair generates a new RSA key pair with the specified bit size

func PrivateKeyFromBase64

func PrivateKeyFromBase64(buf []byte) (*rsa.PrivateKey, error)

PrivateKeyFromBase64 decodes a base64 encoded PEM string and parses it into an RSA private key

func ReadPrivateKeyFromFile

func ReadPrivateKeyFromFile(privateKeyPath string) (*rsa.PrivateKey, error)

ReadPrivateKeyFromFile reads and parses an RSA private key from a file

func ReadPublicKeyFromFile

func ReadPublicKeyFromFile(publicKeyPath string) (*rsa.PublicKey, error)

ReadPublicKeyFromFile reads and parses an RSA public key from a file

func WriteKeyPairToFiles

func WriteKeyPairToFiles(privateKey *rsa.PrivateKey, privateKeyPath, publicKeyPath string) error

WriteKeyPairToFiles writes RSA key pair to files with specified permissions

Types

This section is empty.

Jump to

Keyboard shortcuts

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