Documentation ¶
Overview ¶
Package security contains functions to encrypt and decrypt data. These functions where created/based upon: https://github.com/gtank/cryptopasta.
Index ¶
Constants ¶
View Source
const ( // HashLength is the length of the hash byte slice. HashLength = 16 // KeyLength is the length of the key byte slice. KeyLength = 32 )
Variables ¶
View Source
var ( // ErrMalformedData is returned with the provided data is erroneous. ErrMalformedData = errors.New("malformed data") // ErrInvalidKey is returned when the provided key is invalid. ErrInvalidKey = errors.New("invalid key") // ErrInvalidKeyLength is returned when the provided key is not the correct size. ErrInvalidKeyLength = errors.New("invalid key length, must be " + strconv.Itoa(KeyLength) + " bytes") )
Functions ¶
func ComparePasswordAndKey ¶
ComparePasswordAndKey compares the provided password with the provided key.
func NewSHA256FromPassword ¶ added in v0.3.0
NewSHA256FromPassword creates a new SHA256 from the provided password.
Types ¶
type Key ¶
type Key struct {
Value, Salt []byte
}
Key contains a hashed value and the salt used to hash it.
func NewKeyFromPassword ¶
NewKeyFromPassword creates a new key from the provided password using argon2id.
Click to show internal directories.
Click to hide internal directories.