encryption

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const HASH_LENGTH = 32

Variables

This section is empty.

Functions

func FastHash

func FastHash(data interface{}) string

FastHash - sha1 hash the given data and return the hash as hex string

func GenerateKeys

func GenerateKeys() (publicKey string, privateKey string, err error)

GenerateKeys - Generate assymetric private/public keys

func GenerateKeysBytes

func GenerateKeysBytes() ([]byte, []byte, error)

GenerateKeysBytes - Generate assymetric private/public keys

func Hash

func Hash(data interface{}) string

Hash - hash the given data and return the hash as hex string

func RawFastHash

func RawFastHash(data interface{}) []byte

RawFastHash - Logic to sha1 hash the text and return the hash bytes

func RawHash

func RawHash(data interface{}) []byte

RawHash - Logic to hash the text and return the hash bytes

func ReadKeys

func ReadKeys(reader io.Reader) (publicKey string, privateKey string, publicIp string, port string)

ReadKeys - reads a publicKey and a privateKey from a Reader. They are assumed to be in two separate lines one followed by the other

func Sign

func Sign(privateKey interface{}, hash interface{}) (string, error)

Sign - given a private key and data, compute it's signature

func Verify

func Verify(publicKey interface{}, signature string, hash string) (bool, error)

Verify - given a public key and a signature and the hash used to create the signature, verify the signature

Types

type HashBytes

type HashBytes [HASH_LENGTH]byte

type SignerVerifier

type SignerVerifier interface {
	Sign(hash string) (string, error)
	Verify(signature string, hash string) (bool, error)
}

SignerVerifier - an interface that can sign a hash and verify a signature and hash

Jump to

Keyboard shortcuts

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