passwords

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

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

Go to latest
Published: Jun 30, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

passwords

Build Status

Golang实现的密码加密方法.

Installation

go get https://github.com/lifei6671/passwords.git

Example

package main

import(
    "fmt"
    "log"

    "github.com/lifei6671/passwords"
)

func main() {
        //加密一个密码
        password,err := passwords.PasswordHash("123456")
        
        if err != nil {
                log.Fatal(err)
        }
        fmt.Printf("%s",password)
        //校验密码和已加密的数据是否一致
        err = passwords.PasswordVerify("123456",password)
        
        if err != nil {
            log.Fatal(err)
        }
}

License

Apache Licensed. See LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash = errors.New("bcrypt: the provided hash is not in the correct format")
)

Functions

func PasswordHash

func PasswordHash(password string) (string, error)

加密一个字符串.

func PasswordVerify

func PasswordVerify(password string, hash_password string) error

校验一个字符串和加密后的字符串是否一致.

func RandomBytes

func RandomBytes(n int) []byte

生成指定长度的随机byte数组.

func RandomInt

func RandomInt(min, max int) int

获取指定区间的随机数.

Types

This section is empty.

Jump to

Keyboard shortcuts

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