Documentation ¶
Overview ¶
Package cryptoz provides various utilities for working with symmetric and asymmetric encryption.
Index ¶
- Constants
- func MustDecryptAES(key, ciphertext string) string
- func MustEncryptAES(key, plaintext string) string
- func MustGenerateRandomAESKey() string
- func MustPEMToRSAPrivateKey(buf []byte) *rsa.PrivateKey
- func MustPEMToRSAPublicKey(buf []byte) *rsa.PublicKey
- func PEMToRSAPrivateKey(buf []byte) (*rsa.PrivateKey, error)
- func PEMToRSAPublicKey(buf []byte) (*rsa.PublicKey, error)
- func RSAPrivateKeyToPEM(key *rsa.PrivateKey) []byte
- func RSAPublicKeyToPEM(key *rsa.PublicKey) []byte
Constants ¶
const ( CiphertextPrefix = "enc:" KeyLen = 32 )
AES constants.
Variables ¶
This section is empty.
Functions ¶
func MustDecryptAES ¶ added in v0.12.0
MustDecryptAES decrypts a ciphertext encrypted by MustEncryptAES. The key must consist of 32 bytes, hex-encoded. The ciphertext must be base64-encoded, prefixed with "enc:".
func MustEncryptAES ¶ added in v0.12.0
MustEncryptAES encrypts the given plaintext using symmetric AES, GCM mode. The key must consist of 32 bytes, hex-encoded. The ciphertext will be base64-encoded, prefixed with "enc:".
func MustGenerateRandomAESKey ¶ added in v0.12.0
func MustGenerateRandomAESKey() string
MustGenerateRandomAESKey generates a random AES key.
func MustPEMToRSAPrivateKey ¶
func MustPEMToRSAPrivateKey(buf []byte) *rsa.PrivateKey
MustPEMToRSAPrivateKey is like PEMToRSAPrivateKey but panics on error.
func MustPEMToRSAPublicKey ¶
MustPEMToRSAPublicKey is like PEMToRSAPublicKey but panics on error.
func PEMToRSAPrivateKey ¶
func PEMToRSAPrivateKey(buf []byte) (*rsa.PrivateKey, error)
PEMToRSAPrivateKey tries to find and parse a *rsa.PrivateKey in the given PEM file.
func PEMToRSAPublicKey ¶
PEMToRSAPublicKey tries to find and parse a *rsa.PublicKey in the given PEM file.
func RSAPrivateKeyToPEM ¶
func RSAPrivateKeyToPEM(key *rsa.PrivateKey) []byte
RSAPrivateKeyToPEM encodes a *rsa.PrivateKey to PEM format.
func RSAPublicKeyToPEM ¶
RSAPublicKeyToPEM encodes a *rsa.PublicKey to PEM format.
Types ¶
This section is empty.