Documentation ¶
Index ¶
- Constants
- Variables
- func CreateHash(key string) string
- func CreatePassword(length int, hasNumbers bool, hasSymbols bool) string
- func Decrypt(data []byte, passphrase, cipher string) ([]byte, error)
- func Encrypt(data []byte, passphrase, cipher string) ([]byte, error)
- func GenerateKey(passphrase string) (*[KeySize]byte, error)
- func GenerateNonce() (*[NonceSize]byte, error)
- func GetCipher(cipher string) string
- func HexDecrypt(entry, salt, cipher string) (string, error)
- func HexEncrypt(entry, salt, cipher string) (string, error)
- func InList(a string, list []string) bool
- type Cipher
- type CipherAES
- type CipherNaCl
Constants ¶
View Source
const ( // KeySize is the size of a NaCl secret key KeySize = 32 // NonceSize is the size of a NaCl nonce NonceSize = 24 )
Variables ¶
View Source
var ( // ErrEncrypt is returned when encryption fails. ErrEncrypt = errors.New("secret: encryption failed") // ErrDecrypt is returned when decryption fails. ErrDecrypt = errors.New("secret: decryption failed") )
View Source
var SupportedCiphers = []string{"aes", "nacl"}
SupportedCiphers provides list of supported ciphers
Functions ¶
func CreatePassword ¶
CreatePassword creates password of certain length
func Decrypt ¶
Decrypt wrapper function to decrypt given binary data blob using given passphrase and cipher
func Encrypt ¶
Encrypt wrapper function to encrypt given binary data blob using given passphrase and cipher
func GenerateKey ¶
GenerateKey creates a new secret key either randomly if input key is not provided or via key hash
func GenerateNonce ¶
GenerateNonce creates a new random nonce.
func HexDecrypt ¶ added in v0.0.2
HexDecript decrypts hex encoded cipher string
func HexEncrypt ¶ added in v0.0.2
HexEncrypt entry entry into hex encoded cipher string
Types ¶
type Cipher ¶
type Cipher interface { Encript(data []byte, key string) ([]byte, error) Decript(data []byte, key string) ([]byte, error) }
Cipher defines cipher interface
type CipherAES ¶
type CipherAES struct { }
CipherAES represents AES Cipher
type CipherNaCl ¶
type CipherNaCl struct { }
CipherNaCl represents NaCl Cipher
Click to show internal directories.
Click to hide internal directories.