cryptoUtils

package module
v0.0.0-...-7553e76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2020 License: CC0-1.0 Imports: 14 Imported by: 0

README

crypto-utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPbdkf2Settings = Pbkdf2Settings{
	Hasher:         "pbkdf2_sha256",
	IterationCount: 180000,
	SaltLen:        12,
	KeyLength:      32,
}

Functions

func Base64Decode

func Base64Decode(data string) ([]byte, error)

func Base64Encode

func Base64Encode(data []byte) string

func RandomBytes

func RandomBytes(saltLength int) ([]byte, error)

func ReadRandom

func ReadRandom(data []byte) error

func SplitOne

func SplitOne(data string) (string, string)

func SplitOneBytes

func SplitOneBytes(data []byte) ([]byte, []byte)

Types

type Pbkdf2Hash

type Pbkdf2Hash struct {
	Settings Pbkdf2Settings
	Salt     []byte
	Hash     []byte
}

func ParsePbkdf2Hash

func ParsePbkdf2Hash(data string) (*Pbkdf2Hash, string, error)

func (*Pbkdf2Hash) String

func (p *Pbkdf2Hash) String() string

func (*Pbkdf2Hash) Verify

func (p *Pbkdf2Hash) Verify(pass []byte) bool

type Pbkdf2Settings

type Pbkdf2Settings struct {
	Hasher         string
	IterationCount int
	SaltLen        int
	KeyLength      int
}

func ParsePbkdf2Settings

func ParsePbkdf2Settings(data string) (*Pbkdf2Settings, string, error)

func (Pbkdf2Settings) Hash

func (p Pbkdf2Settings) Hash(pass []byte, salt []byte) *Pbkdf2Hash

func (Pbkdf2Settings) String

func (p Pbkdf2Settings) String() string

type Secretbox

type Secretbox struct {
	Settings Pbkdf2Settings
	PassSalt []byte
	Nonce    [24]byte
	Data     []byte
}

func ParseSecretbox

func ParseSecretbox(input string) (*Secretbox, error)

func SecretboxEncrypt

func SecretboxEncrypt(pass, payload string) (*Secretbox, error)

func (*Secretbox) Decrypt

func (s *Secretbox) Decrypt(pass string) (string, error)

func (*Secretbox) String

func (s *Secretbox) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL