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(decryptedText []byte, key []byte) ([]byte, error)
- func Argon2CompareHash(hashedPassword []byte, password []byte) error
- func Argon2GenerateHash(password []byte, memory uint32, time uint32, threads uint8, saltLen int, ...) ([]byte, error)
- func BcryptCompareHash(hashedPassword []byte, password []byte) error
- func BcryptGenerateHash(password []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 GenerateRandomToken(length int, upperCase bool, lowerCase bool, digits bool, symbols bool) (string, error)
- func RSADecryptWithOAEP(encryptedText []byte, privKey *rsa.PrivateKey, label []byte) ([]byte, error)
- func RSAEncryptWithOAEP(decryptedText []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(text []byte, privKey *rsa.PrivateKey) ([]byte, error)
- func RSAVerifyWithPSS(text []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 decrypted text using the key.
func Argon2CompareHash ¶ added in v0.2.0
Argon2CompareHash compares an hashed password with its plain equivalent.
func Argon2GenerateHash ¶ added in v0.2.0
func Argon2GenerateHash(password []byte, memory uint32, time uint32, threads uint8, saltLen int, keyLen uint32) ([]byte, error)
Argon2GenerateHash generates a new hash from a 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 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 GenerateRandomToken ¶
func GenerateRandomToken(length int, upperCase bool, lowerCase bool, digits bool, symbols bool) (string, error)
GenerateRandomToken generates a random token.
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 decrypted 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(text []byte, privKey *rsa.PrivateKey) ([]byte, error)
RSASignWithPSS signs a text using a private key.
func RSAVerifyWithPSS ¶ added in v0.2.0
RSAVerifyWithPSS verifies a text using a public key.
Types ¶
This section is empty.