Documentation
¶
Overview ¶
Package secure is a simple package to easily work with the most common cryptography functions.
Index ¶
- func CompareArgon2IDHash(hashedPassword []byte, password []byte) error
- func CompareBcryptHash(hashedPassword []byte, password []byte) error
- func DecodeBase64(data []byte) ([]byte, error)
- func DecryptAesAEAD(encryptedText []byte, key []byte) ([]byte, error)
- func DecryptRsaOAEP(encryptedText []byte, privKey *rsa.PrivateKey, label []byte) ([]byte, error)
- func DeriveScryptKey(password []byte, salt []byte) ([]byte, []byte, error)
- func EncodeBase64(data []byte) []byte
- func EncryptAesAEAD(decryptedText []byte, key []byte) ([]byte, error)
- func EncryptRsaOAEP(decryptedText []byte, pubKey *rsa.PublicKey, label []byte) ([]byte, error)
- func ExportRsaPrivateKeyAsPem(privKey *rsa.PrivateKey) []byte
- func ExportRsaPublicKeyAsPem(pubKey *rsa.PublicKey) ([]byte, error)
- func GenerateArgon2IDHash(password []byte, memory uint32, time uint32, threads uint8, saltLen int, ...) ([]byte, error)
- func GenerateBcryptHash(password []byte, cost int) ([]byte, error)
- func GenerateHumanPassword(letters int, digits int) (string, error)
- func GenerateRandomToken(length int, upperCase bool, lowerCase bool, digits bool, symbols bool) (string, error)
- func GenerateRsaKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
- func ParseRsaPrivateKeyFromPem(privPem []byte) (*rsa.PrivateKey, error)
- func ParseRsaPublicKeyFromPem(pubPem []byte) (*rsa.PublicKey, error)
- func SignRsaPSS(text []byte, privKey *rsa.PrivateKey) ([]byte, error)
- func VerifyRsaPSS(text []byte, signature []byte, pubKey *rsa.PublicKey) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareArgon2IDHash ¶ added in v0.1.4
CompareArgon2IDHash compares an hashed password with its plain equivalent.
func CompareBcryptHash ¶
CompareBcryptHash compares an hashed password with its plain equivalent.
func DecodeBase64 ¶
DecodeBase64 decodes data in base64 format.
func DecryptAesAEAD ¶
DecryptAesAEAD decrypts an encrypted text using the key.
func DecryptRsaOAEP ¶
DecryptRsaOAEP decrypts an encrypted text using a private key.
func DeriveScryptKey ¶
DeriveScryptKey derives a 32-bytes key from a variable length password.
func EncodeBase64 ¶
EncodeBase64 encodes data in base64 format.
func EncryptAesAEAD ¶
EncryptAesAEAD encrypts a decrypted text using the key.
func EncryptRsaOAEP ¶
EncryptRsaOAEP encrypts a decrypted text using a public key.
func ExportRsaPrivateKeyAsPem ¶
func ExportRsaPrivateKeyAsPem(privKey *rsa.PrivateKey) []byte
ExportRsaPrivateKeyAsPem encodes a private key in a PEM block.
func ExportRsaPublicKeyAsPem ¶
ExportRsaPublicKeyAsPem encodes a public key in a PEM block.
func GenerateArgon2IDHash ¶ added in v0.1.4
func GenerateArgon2IDHash(password []byte, memory uint32, time uint32, threads uint8, saltLen int, keyLen uint32) ([]byte, error)
GenerateArgon2IDHash generates a new hash from a password with the given parameters.
func GenerateBcryptHash ¶
GenerateBcryptHash generates a new hash from a password at the given cost.
func GenerateHumanPassword ¶
GenerateHumanPassword generates a human readable password.
func GenerateRandomToken ¶
func GenerateRandomToken(length int, upperCase bool, lowerCase bool, digits bool, symbols bool) (string, error)
GenerateRandomToken generates a random token.
func GenerateRsaKeyPair ¶
func GenerateRsaKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
GenerateRsaKeyPair generates a key pair from a variable bit size.
func ParseRsaPrivateKeyFromPem ¶
func ParseRsaPrivateKeyFromPem(privPem []byte) (*rsa.PrivateKey, error)
ParseRsaPrivateKeyFromPem decodes a private key from a PEM block.
func ParseRsaPublicKeyFromPem ¶
ParseRsaPublicKeyFromPem decodes a public key from a PEM block.
func SignRsaPSS ¶
func SignRsaPSS(text []byte, privKey *rsa.PrivateKey) ([]byte, error)
SignRsaPSS signs a text using a private key.
Types ¶
This section is empty.