utils

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64DecryptWithPrivateKey

func Base64DecryptWithPrivateKey(ciphertextEnc string, priv *rsa.PrivateKey) []byte

DecryptWithPrivateKey decrypts base64 encoded data with private key

func Base64EncryptWithPublicKey

func Base64EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) string

EncryptWithPublicKey encrypts data with public key and encode it with base64

func Base64ToPublicKey

func Base64ToPublicKey(pub string) *rsa.PublicKey

Base64ToPublicKey base64 encoded to public key

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) *rsa.PrivateKey

BytesToPrivateKey bytes to private key

func ChunkAndEncrypt

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

Split message in multiple chunk before encrypt it to avoid the key size limitation

func DecryptChunked

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

Decrypt a message which has been encrypted using ChunkAndEncrypt

func DecryptWithPrivateKey

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

DecryptWithPrivateKey decrypts data with private key

func EncryptWithPublicKey

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

EncryptWithPublicKey encrypts data with public key

func GenerateKeyPair

func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)

GenerateKeyPair generates a new key pair

func PrivateKeyToBytes

func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte

PrivateKeyToBytes private key to bytes

func PublicKeyToBase64

func PublicKeyToBase64(pub *rsa.PublicKey) string

PublicKeyToBytes public key to base64 encoding

Types

This section is empty.

Jump to

Keyboard shortcuts

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