Documentation
¶
Index ¶
- func DecryptStringWithAES(encryptedText string, key []byte) (string, error)
- func EncryptStringWithAES(plainText string, key []byte) (string, error)
- func GenerateAESKey() (string, error)
- func GenerateRandomPassword(ctx context.Context, length int, ...) string
- func PKCS7Pad(input []byte, blockSize int) []byte
- func PKCS7Unpad(input []byte) ([]byte, error)
- func RandomNumber(max int) int
- func RandomString(strSize int) string
- type CertInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptStringWithAES ¶
DecryptStringWithAES takes an encrypted, base64-encoded string and a key and returns the plaintext form of the string.
func EncryptStringWithAES ¶
EncryptStringWithAES takes a string and a key and returns the encrypted, base64-encoded form of the string.
func GenerateAESKey ¶
GenerateAESKey generates a cryptographically random 32-byte key, returned as a base64-encoded string.
func GenerateRandomPassword ¶
func PKCS7Pad ¶
PKCS7Pad will pad the input to a multiple of blocksize according to PKCS#7 standard.
func PKCS7Unpad ¶
PKCS7Unpad will remove the padding from input according to PKCS#7 standard.
func RandomNumber ¶
RandomNumber will generate a cryptographically secure random number in the range of [0, max).
func RandomString ¶
RandomString returns a string of the specified length consisting only of alphabetic characters.
Types ¶
type CertInfo ¶
type CertInfo struct { CAKey string CACert string ServerKey string ServerCert string ClientKey string ClientCert string }
func MakeHTTPCertInfo ¶
MakeHTTPCertInfo generates a CA key and cert, then uses that key to sign two other keys and certs, one for a TLS server and one for a TLS client. None of the parameters are configurable...the serial numbers and principal names are hardcoded, the validity period is hardcoded to 1970-2070, and the algorithm and key size are hardcoded to 521-bit elliptic curve.