crypto

package
v0.0.0-...-8a3d261 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const HashBits = 8 * HashLen
View Source
const HashLen = 64

Variables

View Source
var EmptyHash = Hash{}

Functions

func Decrypt

func Decrypt(wrapped, public, private string) (string, error)

func Encrypt

func Encrypt(message, public, private string) (string, error)

func FirstDifference

func FirstDifference(a, b Hash) int

func GenerateEd25519KeypairFromSecret

func GenerateEd25519KeypairFromSecret(secret, salt string) (public string, private string)

func GenerateRandomBoxKeypair

func GenerateRandomBoxKeypair() (public string, private string)

func GenerateRandomEd25519Keypair

func GenerateRandomEd25519Keypair() (public string, private string)

func GenerateRandomToken

func GenerateRandomToken(n int) string

func IsSmaller

func IsSmaller(a, b Hash) bool

func Sign

func Sign(privateKey string, signable Signable) (string, error)

func Verify

func Verify(publicKey string, signable Signable, signature string) error

Types

type Hash

type Hash [HashLen]byte
var LastHash Hash

func CombineHashes

func CombineHashes(a, b Hash) Hash

func HashFromBytes

func HashFromBytes(bytes []byte) Hash

func HashFromString

func HashFromString(s string) (Hash, error)

func HashString

func HashString(s string) Hash

func MaxHash

func MaxHash(a, b Hash) Hash

func NextHash

func NextHash(h Hash) Hash

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (*Hash) GetBit

func (h *Hash) GetBit(idx int) int

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

func (*Hash) SetBit

func (h *Hash) SetBit(idx, value int)

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

func NewHasher

func NewHasher() *Hasher

func (*Hasher) Sum

func (h *Hasher) Sum() Hash

func (*Hasher) Write

func (h *Hasher) Write(data []byte) (int, error)

func (*Hasher) WriteBool

func (h *Hasher) WriteBool(b bool)

func (*Hasher) WriteString

func (h *Hasher) WriteString(s string)

func (*Hasher) WriteUint64

func (h *Hasher) WriteUint64(i uint64)

type Signable

type Signable interface {
	SigningTypeName() string
	Hash() Hash
}

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(privateKey string) (*Signer, error)

func (*Signer) Sign

func (s *Signer) Sign(x Signable) string

Jump to

Keyboard shortcuts

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