utils

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(username, pwd, salt, key string) bool

CheckPassword allows to compare password from request with salted value from database.

func GenSalt

func GenSalt(args ...string) string

GenSalt generates a salt from given data. It also appends current time in nanoseconds to args before salt generation. Salt generator is a chained sha256 (salt = sha256(salt, args[i])). Number of iterations is a number of args + 1. Result salt returned in base64-encoded string.

func GetByteKey

func GetByteKey(username, pwd, salt string) []byte

GetByteKey generates a salted password using pbkdf2 algorithm.

func GetKey

func GetKey(username, pwd, salt string) string

GetKey works same as GetByteKey but returns result as string.

func SecureRandomBytes

func SecureRandomBytes(length int) ([]byte, error)

SecureRandomBytes returns the requested number of bytes using crypto/rand

func SecureRandomString

func SecureRandomString(length int) (ret string, err error)

SecureRandomString securly generates random string

func WebAPIPasswordEncode

func WebAPIPasswordEncode(username, plainPass string) string

WebAPIPasswordEncode needed to encode password with function from old web-api to allow old users to login.

Types

This section is empty.

Jump to

Keyboard shortcuts

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