crypto

package
v0.0.0-...-2f2617e Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AES_KEY_SIZE = 32
View Source
const RSA_KEY_SIZE = 2048

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(cypherText []byte, key AesKey) ([]byte, error)

Decrypts a buffer with AES

func AesEncrypt

func AesEncrypt(plainText []byte, key AesKey) ([]byte, error)

Encrypts a buffer with AES

func ExportRsaPrivateKeyAsPemStr

func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string

func ExportRsaPublicKeyAsPemStr

func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) (string, error)

func ParseRsaPrivateKeyFromPemStr

func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)

func ParseRsaPublicKeyFromPemStr

func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error)

func RsaDecrypt

func RsaDecrypt(cipherText []byte, privateKey *rsa.PrivateKey) ([]byte, error)

func RsaEncrypt

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

Types

type AesKey

type AesKey []byte

func NewRandomAesKey

func NewRandomAesKey(keySize int) (AesKey, error)

Creates a new random AES key

type Keypair

type Keypair struct {
	Public  *rsa.PublicKey
	Private *rsa.PrivateKey
}

func NewRandomRsaKeypair

func NewRandomRsaKeypair(keySize int) (*Keypair, error)

Jump to

Keyboard shortcuts

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