Documentation ¶
Index ¶
- Constants
- func Sha256Hash(key string) []byte
- type Decryptor
- type EncryptTool
- func (e *EncryptTool) Compare(data, hash []byte) (bool, error)
- func (e *EncryptTool) Decrypt(data []byte) ([]byte, error)
- func (e *EncryptTool) DeriveKey(salt []byte) ([]byte, []byte, error)
- func (e *EncryptTool) Encrypt(data []byte) ([]byte, error)
- func (e *EncryptTool) Hash(data []byte) ([]byte, error)
- type EncryptToolOption
- func WithKeyLen(keyLen uint32) EncryptToolOption
- func WithMemory(memory uint32) EncryptToolOption
- func WithPassphrase(passphrase []byte) EncryptToolOption
- func WithPassphraseText(passphrase string) EncryptToolOption
- func WithThreads(threads uint8) EncryptToolOption
- func WithTime(time uint32) EncryptToolOption
- type Encryptor
- type Hasher
Constants ¶
View Source
const ( CIPHER_KEY_LEN = 32 SALT_KEY_LEN = 32 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EncryptTool ¶
EncryptTool implements Hasher, Encryptor and Decryptor
func New ¶
func New(opts ...EncryptToolOption) (*EncryptTool, error)
New created a Encryptor/Decryptor/Hasher object with given options
func (*EncryptTool) Compare ¶
func (e *EncryptTool) Compare(data, hash []byte) (bool, error)
Compare compares data which is hashed with Hash
func (*EncryptTool) Decrypt ¶
func (e *EncryptTool) Decrypt(data []byte) ([]byte, error)
Decrypt decrypts given data
func (*EncryptTool) DeriveKey ¶
func (e *EncryptTool) DeriveKey(salt []byte) ([]byte, []byte, error)
DeriveKey generates a key based on passphrase and salt if given
type EncryptToolOption ¶
type EncryptToolOption func(*EncryptTool)
EncryptToolOption allows you to define options
func WithKeyLen ¶
func WithKeyLen(keyLen uint32) EncryptToolOption
WithKeyLen option set argon2id key Length
func WithMemory ¶
func WithMemory(memory uint32) EncryptToolOption
WithMemory option set argon2id memory
func WithPassphrase ¶
func WithPassphrase(passphrase []byte) EncryptToolOption
WithPassphrase option sets passphrase as encryption key
func WithPassphraseText ¶
func WithPassphraseText(passphrase string) EncryptToolOption
WithPassphraseText option sets sha256 hash of passphrase as encryption key
func WithThreads ¶
func WithThreads(threads uint8) EncryptToolOption
WithThreads option set argon2id threads
Click to show internal directories.
Click to hide internal directories.