crypto

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswordHash

func ComparePasswordHash(pwd, hash, salt string) (bool, error)

func Decrypt

func Decrypt(key, text string) (string, error)

Decrypt text using the encryption key

func Encrypt

func Encrypt(key, text string) (string, error)

Encrypt text using the encyption key

func MD5

func MD5(b []byte) string

MD5 is generally faster to compute than SHA-256

func NewEncryptionKey

func NewEncryptionKey(size uint8) (string, error)

NewEncryptionKey will generate new key as base64 encoded string

should be of 16, 24 or 32 bytes in length

func NewPersistedED25519

func NewPersistedED25519() ([]byte, []byte, error)

NewPersistedED25519 public & private keys

func ParseEdPrivateKey

func ParseEdPrivateKey(d []byte) (ed25519.PrivateKey, error)

func ParseEdPublicKey

func ParseEdPublicKey(d []byte) (ed25519.PublicKey, error)

func PasswordHash

func PasswordHash(pwd string) (hash, salt string, err error)

PasswordHash using Argon2id

https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#argon2id

func RandomBytes

func RandomBytes(length uint8) ([]byte, error)

RandomBytes generates totally random bytes, each byte is generated by [0,255] range

func RandomBytesHex

func RandomBytesHex(length uint8) (string, error)

func SHA256

func SHA256(b []byte) string

SHA256 Sum256 is generally preferred over md5.hash due to its superior security and resistance to collision attacks

Types

This section is empty.

Jump to

Keyboard shortcuts

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