crypto

package module
v0.0.0-...-cae1ba5 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2015 License: Apache-2.0 Imports: 15 Imported by: 6

README

crypto

Build Status GoDoc

crypto is a cryptographic toolkit for the Go programming language.

Getting Started

Install the package, along with executable binary helper (go 1.4 and greater is required):

$ go get -v github.com/goanywhere/crypto

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encrypt

func Encrypt(src string) (secret string)

Encrypt creates a new password hash using a strong one-way bcrypt algorithm. Source secret is hashed with the given key (if set) before actual bcrypting.

func Random

func Random(length int) string

Random creates a URL-safe random string which is based on the implementation with cryptographically secure pseudorandom number.

func Verify

func Verify(src, secret string) bool

Verify checks that if the given hash matches the given source secret. Source secret is hashed with the given key (if set) before actual bcrypting.

Types

type Signature

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

func NewSignature

func NewSignature(secret string) *Signature

NewSignature creates a signature with secret salt for encode/decode consequent values.

func (*Signature) Decode

func (self *Signature) Decode(key, value string) (src []byte, err error)

Decode unpacks the source string to original values. Pattern:

  1. signed value => base64 decode => nano|src(hex)|crc
  2. verify crc
  3. verify nano timestamp

func (*Signature) Encode

func (self *Signature) Encode(key string, src []byte) (value string, err error)

Encode creates a checksum value for the given source using key, timestamp, crc. Pattern:

  1. key|nano|src(hex) => hmac.sha1 => crc
  2. nano|src(hex)|crc => base64 encode => signed value

NOTE struct value must be registered using gob.Register() first.

Jump to

Keyboard shortcuts

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