crypto

package
v0.0.0-...-5c48035 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashMD5    = 0
	HashSHA1   = 1
	HashSHA256 = 3
	//384
	HashSHA512 = 6
)

Hash Type

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(data []byte, passphrase string) ([]byte, error)

func AESEncrypt

func AESEncrypt(data []byte, passphrase string) []byte

func Decode

func Decode(src string) string

func Encode

func Encode(data []byte) string

func Hash

func Hash(b []byte, hashType int) []byte

Hash supports md5,sha1,sha256,sha512

func MD5

func MD5(data string) string

MD5 md5 hash

func SHA1

func SHA1(data string) string

SHA1 SHA1 hash

func SHA256

func SHA256(data string) string

SHA256 SHA256 hash

func SHA512

func SHA512(data string) string

SHA512 SHA512 hash

Types

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

Represents the two mathematical components of an ECDSA signature once decomposed.

type Envelope

type Envelope struct {
	RawMessage json.RawMessage `json:"message"`
	Message    interface{}     `json:"-"`
	Signature  string          `json:"signature"`
}

Encapsulates the overall message we're trying to decode and validate.

func NewEnvelopeFromJSON

func NewEnvelopeFromJSON(s string) (*Envelope, error)

Attempts to create a new envelope structure from the given JSON string.

func (*Envelope) Validate

func (e *Envelope) Validate(publicKey *ecdsa.PublicKey) error

The central validation routine that validates this message against the given public key. On success, returns nil, on failure returns a relevant error.

type MessageBody

type MessageBody struct {
	Type        string          `json:"type"`
	UserID      uint32          `json:"userId"`
	Transaction json.RawMessage `json:"transaction"`
}

The body of the message to be contained in the Message field of our Envelope structure.

Jump to

Keyboard shortcuts

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