cryptography

package
v0.0.0-...-535fdf0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptAes

func DecryptAes(ciphertext []byte, key []byte) ([]byte, error)

DecryptAes takes in a cipher text and decryptes the data. They key needs to be either 16, 24 or 32 bits.

func DecryptWithRsaPrivateKey

func DecryptWithRsaPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)

Decrypts data with private RSA key

func EncryptAes

func EncryptAes(data []byte, key []byte) ([]byte, error)

EncryptAes takes in a plaintext string and a key and returns the encrypted data. They key needs to be either 16, 24 or 32 bits.

func EncryptWithRsaPublicKey

func EncryptWithRsaPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error)

Encrypts data with public RSA key

func GenerateMd5FromStrings

func GenerateMd5FromStrings(strings ...string) (md5Hash string)

func GenerateRSAKeyPair

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

Generates a new RSA key pair. 2048 bits is considered the standard.

func GenerateRandomBytes

func GenerateRandomBytes(n int) []byte

Generates cryptographically secure random byte array of length n

func RSAPublicKeyToString

func RSAPublicKeyToString(pub *rsa.PublicKey) string

RSA public key to base64 encoded string

func RsaPrivateKeyToString

func RsaPrivateKeyToString(priv *rsa.PrivateKey) string

RSA private key to base64 encoded string

func StringToRsaPrivateKey

func StringToRsaPrivateKey(priv string) (*rsa.PrivateKey, error)

Given a base64 encoded RSA private key, returns an *rsa.PrivateKey object

func StringToRsaPublicKey

func StringToRsaPublicKey(pub string) (*rsa.PublicKey, error)

Given a base64 encoded RSA public key, returns an *rsa.PublicKey object

Types

This section is empty.

Jump to

Keyboard shortcuts

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