helper

package
v0.0.0-...-660965e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrivateKey is the private key
	PrivateKey ed25519.PrivateKey = MustDecodeKey(os.Getenv("PRIVATE_KEY"))
	// PublicKey is the private key
	PublicKey ed25519.PublicKey = MustDecodeKey(os.Getenv("PUBLIC_KEY"))
)

Functions

func ClientIDAndSecretKey

func ClientIDAndSecretKey(prv ed25519.PrivateKey) (ID string, secret []byte, err error)

ClientIDAndSecretKey generate new signed client and secret key

func DecodeKey

func DecodeKey(key string) (d []byte, err error)

DecodeKey decode string key into bytes

func EncodeKey

func EncodeKey(key []byte) string

EncodeKey from byte to be a decent readable string

func FatalError

func FatalError(err error, m string)

FatalError print error(if any) and exists the program

func GenerateKey

func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, error)

GenerateKey generate new private and public key

func InstallHTML

func InstallHTML() string

InstallHTML return html for installing app

func MustDecodeKey

func MustDecodeKey(key string) []byte

MustDecodeKey decode key or panic

func PanicError

func PanicError(err error, m string)

PanicError it panics

func Print

func Print(v ...interface{})

Print regardless of verbose flag

func PrintError

func PrintError(err error, m string)

PrintError just print an error(if any) as warning

func PrintKey

func PrintKey()

PrintKey it prints generated private and public key or error

func Sign

func Sign(priv ed25519.PrivateKey, message []byte) ([]byte, error)

Sign signs the message with privateKey and returns a signature. it returns nil of []byte and error if the size of the private key is not equal to 64

func TestError

func TestError(t *testing.T, v ...interface{})

TestError equivalent to t.Error with colors

func TestErrorf

func TestErrorf(t *testing.T, format string, v ...interface{})

TestErrorf equivalent to t.Errorf with colors

func TestLog

func TestLog(t *testing.T, v ...interface{})

TestLog equivalent to t.Log with colors

func TestLogf

func TestLogf(t *testing.T, format string, v ...interface{})

TestLogf equivalent to t.Logf with colors

func Verbose

func Verbose(v ...interface{})

Verbose print everything when the verbose flag is set to true

func Verify

func Verify(pub ed25519.PublicKey, message, sign []byte) (bool, error)

Verify reports whether sig is a valid signature of message by publicKey. it returns nil of false and error if the size of the public key is not equal to 32

Types

This section is empty.

Jump to

Keyboard shortcuts

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