Documentation
¶
Overview ¶
Package secure is a simple package to easily work with the most common cryptography functions.
Index ¶
- func AESDecryptWithGCM(encryptedText []byte, key []byte) ([]byte, error)
- func AESEncryptWithGCM(plainText []byte, key []byte) ([]byte, error)
- func Argon2idCompareHash(hashedPassword []byte, password []byte) error
- func Argon2idGenerateHash(plainPassword []byte, memory uint32, time uint32, threads uint8, ...) ([]byte, error)
- func BcryptCompareHash(hashedPassword []byte, password []byte) error
- func BcryptGenerateHash(plainPassword []byte, cost int) ([]byte, error)
- func DecodeBase64(data []byte) ([]byte, error)
- func EncodeBase64(data []byte) []byte
- func GenerateHumanPassword(letters int, digits int) (string, error)
- func GenerateRandomBytes(length int) ([]byte, error)
- func GenerateRandomString(length int, upperCase bool, lowerCase bool, digits bool, symbols bool) (string, error)
- func GenerateRandomStringURLSafe(length int) (string, error)
- func RSADecryptWithOAEP(encryptedText []byte, privKey *rsa.PrivateKey, label []byte) ([]byte, error)
- func RSAEncryptWithOAEP(plainText []byte, pubKey *rsa.PublicKey, label []byte) ([]byte, error)
- func RSAExportPrivateKeyAsPEM(privKey *rsa.PrivateKey) []byte
- func RSAExportPublicKeyAsPEM(pubKey *rsa.PublicKey) ([]byte, error)
- func RSAGenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
- func RSAParsePrivateKeyFromPEM(privPem []byte) (*rsa.PrivateKey, error)
- func RSAParsePublicKeyFromPEM(pubPem []byte) (*rsa.PublicKey, error)
- func RSASignWithPSS(plainText []byte, privKey *rsa.PrivateKey) ([]byte, error)
- func RSAVerifyWithPSS(signedText []byte, signature []byte, pubKey *rsa.PublicKey) error
- func ScryptDeriveKey(password []byte, salt []byte) ([]byte, []byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESDecryptWithGCM ¶ added in v0.2.0
AESDecryptWithGCM decrypts an encrypted text using the key.
func AESEncryptWithGCM ¶ added in v0.2.0
AESEncryptWithGCM encrypts a plain text using the key.
func Argon2idCompareHash ¶ added in v0.2.3
Argon2idCompareHash compares an hashed password with its plain equivalent.
func Argon2idGenerateHash ¶ added in v0.2.3
func Argon2idGenerateHash(plainPassword []byte, memory uint32, time uint32, threads uint8, saltLength int, keyLength uint32) ([]byte, error)
Argon2idGenerateHash generates a new hash from a plain password with the given parameters.
func BcryptCompareHash ¶ added in v0.2.0
BcryptCompareHash compares an hashed password with its plain equivalent.
func BcryptGenerateHash ¶ added in v0.2.0
BcryptGenerateHash generates a new hash from a plain password at the given cost.
func DecodeBase64 ¶
DecodeBase64 decodes data in base64 format.
func EncodeBase64 ¶
EncodeBase64 encodes data in base64 format.
func GenerateHumanPassword ¶
GenerateHumanPassword generates a human readable password.
func GenerateRandomBytes ¶ added in v0.2.2
GenerateRandomBytes generates securely random bytes.
func GenerateRandomString ¶ added in v0.2.2
func GenerateRandomString(length int, upperCase bool, lowerCase bool, digits bool, symbols bool) (string, error)
GenerateRandomString generates a random string.
func GenerateRandomStringURLSafe ¶ added in v0.2.2
GenerateRandomStringURLSafe generates a URL-safe, base64 encoded, random string.
func RSADecryptWithOAEP ¶ added in v0.2.0
func RSADecryptWithOAEP(encryptedText []byte, privKey *rsa.PrivateKey, label []byte) ([]byte, error)
RSADecryptWithOAEP decrypts an encrypted text using a private key.
func RSAEncryptWithOAEP ¶ added in v0.2.0
RSAEncryptWithOAEP encrypts a plain text using a public key.
func RSAExportPrivateKeyAsPEM ¶ added in v0.2.0
func RSAExportPrivateKeyAsPEM(privKey *rsa.PrivateKey) []byte
RSAExportPrivateKeyAsPEM encodes a private key in a PEM block.
func RSAExportPublicKeyAsPEM ¶ added in v0.2.0
RSAExportPublicKeyAsPEM encodes a public key in a PEM block.
func RSAGenerateKeyPair ¶ added in v0.2.0
func RSAGenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
RSAGenerateKeyPair generates a key pair from a variable bit size.
func RSAParsePrivateKeyFromPEM ¶ added in v0.2.0
func RSAParsePrivateKeyFromPEM(privPem []byte) (*rsa.PrivateKey, error)
RSAParsePrivateKeyFromPEM decodes a private key from a PEM block.
func RSAParsePublicKeyFromPEM ¶ added in v0.2.0
RSAParsePublicKeyFromPEM decodes a public key from a PEM block.
func RSASignWithPSS ¶ added in v0.2.0
func RSASignWithPSS(plainText []byte, privKey *rsa.PrivateKey) ([]byte, error)
RSASignWithPSS signs a plain text using a private key.
func RSAVerifyWithPSS ¶ added in v0.2.0
RSAVerifyWithPSS verifies a signed text using a public key.
Types ¶
This section is empty.