crypto

package
v0.0.0-...-1913e9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareWithHashedPassword

func CompareWithHashedPassword(pwd, hashed, pepper string) bool

CompareWithHashedPassword encodes the given pwd and compares it with the hashed one.

func CreateTLSConfig

func CreateTLSConfig(certFile, keyFile, caFile string, insecure bool) (*tls.Config, error)

CreateTLSConfig creates a tls.Config from the specified cert files.

func Decrypt

func Decrypt(ciphertext []byte, key []byte) ([]byte, error)

Decrypt decrypts a salted string.

func DecryptBase64

func DecryptBase64(base64Cipher, key []byte) ([]byte, error)

DecryptBase64 decrypts a salted base64 string.

func Encrypt

func Encrypt(plaintext []byte, key []byte) ([]byte, error)

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

func EncryptBase64(plaintext, key []byte) ([]byte, error)

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 GenPassword

func GenPassword(n int) string

GenPassword generates a password of length n.

func GenPasswordLetter62

func GenPasswordLetter62(n int) string

GenPasswordLetter62 generates a string using alphanumeric.

func GenRandString

func GenRandString(n int) string

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

func HashPassword(pwd, pepper string) ([]byte, error)

HashPassword hmac password and encodes it as base64.

func MD5FromByte

func MD5FromByte(b []byte) string

MD5FromByte returns a base64 encoded MD5 from the given bytes.

func MD5FromFile

func MD5FromFile(pth string) (string, error)

MD5FromFile returns a base64 encoded MD5 from the given file.

func SHA1FromByte

func SHA1FromByte(b []byte) string

SHA1FromByte returns base64 encoded SHA1 from the given bytes.

func SHA1FromFile

func SHA1FromFile(pth string) (string, error)

SHA1FromFile returns a base64 encoded SHA1 from the given file.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL