Documentation ¶
Index ¶
- Variables
- func Decrypt(data, secret string, passwordBased bool, config CipherConfig) (string, error)
- func Encrypt(data, secret string, passwordBased bool, config CipherConfig) (string, error)
- func GenerateRandomBytes(length int) ([]byte, error)
- func PasswordHash(password string, cost int) (string, error)
- func PasswordVerify(password, hash string) bool
- type AES
- type CipherConfig
- type Input
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultCipherConfig = CipherConfig{ Cipher: "AES-128-CBC", AllowedCiphers: map[string][]int{ "AES-128-CBC": {16, 16}, "AES-192-CBC": {16, 24}, "AES-256-CBC": {16, 32}, }, KdfHash: "sha256", MacHash: "sha256", AuthKeyInfo: "AuthorizationKey", DerivationIterations: 100000, }
DefaultCipherConfig is the default cipher configuration
Functions ¶
func Decrypt ¶
func Decrypt(data, secret string, passwordBased bool, config CipherConfig) (string, error)
Decrypt decrypts data using a password or a key
func Encrypt ¶
func Encrypt(data, secret string, passwordBased bool, config CipherConfig) (string, error)
Encrypt encrypts data using a password or a key
func GenerateRandomBytes ¶
GenerateRandomBytes generates random bytes of specified length
func PasswordHash ¶
PasswordHash generates a hash of the password
func PasswordVerify ¶
PasswordVerify validates the password against a given hash
Types ¶
type AES ¶
type AES struct { Text string `json:"text" default:""` Key string `json:"key" default:"jcbase.aes_key__"` Iv string `json:"iv" default:"jcbase.aes_iv___"` }
type CipherConfig ¶
type CipherConfig struct { Cipher string AllowedCiphers map[string][]int KdfHash string MacHash string AuthKeyInfo string DerivationIterations int }
CipherConfig stores the cipher configuration
Click to show internal directories.
Click to hide internal directories.