Documentation ¶
Index ¶
- func CompareWithHashedPassword(pwd, hashed, pepper string) bool
- func CreateTLSConfig(certFile, keyFile, caFile string, insecure bool) (*tls.Config, error)
- func Decrypt(ciphertext []byte, key []byte) ([]byte, error)
- func DecryptBase64(base64Cipher, key []byte) ([]byte, error)
- func Encrypt(plaintext []byte, key []byte) ([]byte, error)
- func EncryptBase64(plaintext, key []byte) ([]byte, error)
- func GenPassword(n int) string
- func GenPasswordLetter62(n int) string
- func GenRandString(n int) string
- func HashPassword(pwd, pepper string) ([]byte, error)
- func MD5FromByte(b []byte) string
- func MD5FromFile(pth string) (string, error)
- func SHA1FromByte(b []byte) string
- func SHA1FromFile(pth string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareWithHashedPassword ¶
CompareWithHashedPassword encodes the given pwd and compares it with the hashed one.
func CreateTLSConfig ¶
CreateTLSConfig creates a tls.Config from the specified cert files.
func DecryptBase64 ¶
DecryptBase64 decrypts a salted base64 string.
func Encrypt ¶
Encrypt symetrically encrpts a plaintext. NewCipher creates and returns a new cipher.Block. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256
func EncryptBase64 ¶
https://stackoverflow.com/questions/47382035/unable-to-decrypt-after-aes-gcm-base64-in-go Problem without base64 encoding: "cipher: message authentication failed" This error occurs when decrypting the encrypted text which was written to a file.
func GenPasswordLetter62 ¶
GenPasswordLetter62 generates a string using alphanumeric.
func GenRandString ¶
GenRandString generates a string starting a alphabet letter and ending with alphanumberica letter. abc2-Cd2 This function can be used to generate a file name, username, file id etc. The collission should be very small if n >= 8
func HashPassword ¶
HashPassword hmac password and encodes it as base64.
func MD5FromByte ¶
MD5FromByte returns a base64 encoded MD5 from the given bytes.
func MD5FromFile ¶
MD5FromFile returns a base64 encoded MD5 from the given file.
func SHA1FromByte ¶
SHA1FromByte returns base64 encoded SHA1 from the given bytes.
func SHA1FromFile ¶
SHA1FromFile returns a base64 encoded SHA1 from the given file.
Types ¶
This section is empty.