Documentation ¶
Overview ¶
package crypto provides helper functions for an established set of crypto libraries (nacl, scrypt)
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultScryptConfig = ScryptConfig{ N: 1 << uint64(15), R: 8, P: 1, }
requires 32MB RAM for under a second (i7).
Functions ¶
func Encrypt ¶
func Encrypt(scryptConfig *ScryptConfig, password string, data []byte) ([]byte, error)
Encrypts given data with nacl/secretbox using a scrypt derived key. The first 24 bytes of the resulting byte slice contain the scrypt configuration. The following 32 bytes contain the scrypt salt. All remaining bytes represent the encrypted data.
func GenerateScryptSalt ¶
Types ¶
type ScryptConfig ¶
type ScryptConfig struct { // CPU/memory cost parameter (logN) N uint64 `json:"n"` // block size parameter (octets) R uint64 `json:"r"` // parallelisation parameter (positive int) P uint64 `json:"p"` }
func DecodeScryptConfig ¶
func DecodeScryptConfig(data []byte) (ScryptConfig, error)
func (ScryptConfig) Encode ¶
func (config ScryptConfig) Encode() []byte
func (ScryptConfig) MemoryRequiredMB ¶
func (config ScryptConfig) MemoryRequiredMB() int
func (ScryptConfig) TimeRequiredMS ¶
func (config ScryptConfig) TimeRequiredMS() (int, error)
Click to show internal directories.
Click to hide internal directories.