crypto

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Unlicense Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const AlgorithmNonceSize int = 12

Variables

This section is empty.

Functions

func B64Decode

func B64Decode(msg string) ([]byte, error)

func B64Encode

func B64Encode(msg []byte) string

func Decrypt

func Decrypt(ciphertextAndNonce, key []byte) ([]byte, error)

func Encrypt

func Encrypt(plaintext, key []byte) ([]byte, error)

func GenerateKey

func GenerateKey(passwordLength, minSpecialChar, minNum, minUpperCase int) string

func GetMD5Hash

func GetMD5Hash(data []byte) string

func RandString

func RandString(n int) string

func RandomRange

func RandomRange(lower, upper int) int

func Sha1

func Sha1(plain string) string

func Sha256

func Sha256(data []byte) string

func XOR

func XOR(input, key string) (output string)

Types

type RSA

type RSA struct {
	// contains filtered or unexported fields
}

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) (r *RSA, err error)

func BytesToPublicKey

func BytesToPublicKey(pub []byte) (r *RSA, err error)

func StringToRSAKey

func StringToRSAKey(str string, bits int) (r *RSA, err error)

func (*RSA) Decrypt

func (r *RSA) Decrypt(ciphertext []byte) (plaintext []byte, err error)

func (*RSA) Encrypt

func (r *RSA) Encrypt(msg []byte) (ciphertext []byte, err error)

func (*RSA) GenerateKeyPair

func (r *RSA) GenerateKeyPair(key io.Reader, bits int) (err error)

GenerateKeyPair generates a new key pair

func (*RSA) PrivateKeyToBytes

func (r *RSA) PrivateKeyToBytes() []byte

func (*RSA) PublicKeyToBytes

func (r *RSA) PublicKeyToBytes() (pubBytes []byte, err error)

Jump to

Keyboard shortcuts

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