crypto

package
v0.0.0-...-6192468 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

crypto

import "github.com/ardanlabs/kit/auth/crypto"

Package crypto provides support for encrypting passwords and generating tokens for authentication support.

func BcryptPassword

func BcryptPassword(pwd string) (string, error)

BcryptPassword uses bcrypt to hash password.

func CompareBcryptHashPassword

func CompareBcryptHashPassword(hash []byte, pwd []byte) error

CompareBcryptHashPassword compares pwd hash to original hash.

func GenerateToken

func GenerateToken(entity SecureEntity) ([]byte, error)

GenerateToken returns a hash for SecureEntity interface.

func IsTokenValid

func IsTokenValid(entity SecureEntity, hash string) error

IsTokenValid checks whether a hash is valid.

func SignedHash

func SignedHash(pwd []byte, salt []byte) ([]byte, error)

SignedHash generates a Signed SHA256 Hash.

type SecureEntity

type SecureEntity interface {
    Pwd() ([]byte, error)
    Salt() ([]byte, error)
}

SecureEntity interface is required for processing and validating tokens.


Generated by godoc2md

Documentation

Overview

Package crypto provides support for encrypting passwords and generating tokens for authentication support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BcryptPassword

func BcryptPassword(pwd string) (string, error)

BcryptPassword uses bcrypt to hash password.

func CompareBcryptHashPassword

func CompareBcryptHashPassword(hash []byte, pwd []byte) error

CompareBcryptHashPassword compares pwd hash to original hash.

func GenerateToken

func GenerateToken(entity SecureEntity) ([]byte, error)

GenerateToken returns a hash for SecureEntity interface.

func IsTokenValid

func IsTokenValid(entity SecureEntity, hash string) error

IsTokenValid checks whether a hash is valid.

func SignedHash

func SignedHash(pwd []byte, salt []byte) ([]byte, error)

SignedHash generates a Signed SHA256 Hash.

Types

type SecureEntity

type SecureEntity interface {
	Pwd() ([]byte, error)
	Salt() ([]byte, error)
}

SecureEntity interface is required for processing and validating tokens.

Jump to

Keyboard shortcuts

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