cryptoext

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstantTimeCompare

func ConstantTimeCompare(a, b string) bool

ConstantTimeCompare performs a constant-time comparison of two strings.

func Decrypt

func Decrypt(ciphertext string, key []byte) (string, error)

Decrypt decrypts a ciphertext string using AES-GCM.

func Encrypt

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

Encrypt encrypts a plaintext string using AES-GCM.

func GenerateBackupCodes

func GenerateBackupCodes(num int) ([]string, error)

GenerateBackupCodes generates a set of backup codes for 2FA.

func GenerateEncryptionKey

func GenerateEncryptionKey() ([]byte, string, error)

GenerateEncryptionKey generates a new encryption key.

func GenerateQRCode

func GenerateQRCode(content string, size int) ([]byte, error)

GenerateQRCode generates a QR code PNG image for the given content.

func GenerateRandomHex

func GenerateRandomHex(length int) string

func GenerateRandomHexString

func GenerateRandomHexString(numBytes int) (string, error)

GenerateRandomHexString generates a random hex string of the specified byte length.

func GenerateSSHKey

func GenerateSSHKey() (pubKey, privKey string, err error)

func GetOrCreateEncryptionKey

func GetOrCreateEncryptionKey(hexKey string) ([]byte, bool, error)

GetOrCreateEncryptionKey gets an encryption key from the provided hex string or generates a new one.

func HashBackupCodes

func HashBackupCodes(codes []string) string

HashBackupCodes hashes all backup codes and joins them.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password using bcrypt.

func MustParseEncryptionKey

func MustParseEncryptionKey(hexKey string) []byte

func ParseEncryptionKey

func ParseEncryptionKey(hexKey string) ([]byte, error)

ParseEncryptionKey parses a hex-encoded encryption key.

func Sha256Hash

func Sha256Hash(input string) string

Sha256Hash returns the SHA-256 hash of the input string in hexadecimal format.

func VerifyPassword

func VerifyPassword(password, hash string) bool

VerifyPassword compares a plaintext password with a bcrypt hash.

Types

This section is empty.

Jump to

Keyboard shortcuts

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