Code Monkey home page Code Monkey logo

gotools's Introduction

My Go Tools (Golang实用工具)

安装 install

使用 go get 下载包

$ go get -u github.com/wangyongtao/gotools

代码示例 (详见 examples):

// main.go
package main

import (
    "fmt"
    "github.com/wangyongtao/gotools/util" // <---- 引入工具库
)

// 演示加密字符串、校验加密结果
func main() {
    fmt.Println("hello, world!")

    // 加密:encrypt
    // 用户密码,需要加密存储
    pwd := "admin"
    hash, _ := util.PasswordHash(pwd)

    fmt.Println("==> 密码加密:")
    fmt.Println("--> 输入的密码:", pwd)
    fmt.Println("--> 生成的hash:", hash)
    // hash: $2a$10$tL00vjlVzidXygcmmW7naObKkI2CgoH9lcaT/DYAFWVAbVO/PVMiu

    // 校验 verify
    // 登录账户时,将用户输入的密码加密后,与数据中查询的加密密码对比,校验通过则说明用户密码输入正确 
    fmt.Println("==> 对比加密结果:")
    match := util.PasswordVerify(pwd, hash)

    fmt.Println("--> 验证结果:", match)
}

推荐 recommend

url remark
github.com/gin-gonic/gin web framework
github.com/labstack/echo web framework
github.com/julienschmidt/httprouter httprouter
github.com/bwmarrin/snowflake unique id generator
github.com/jmoiron/sqlx database
github.com/go-gorm/gorm database ORM
github.com/go-sql-driver/mysql database mysql
github.com/lib/pq database PostgreSQL
github.com/mattn/go-sqlite3 database sqlite3

参考 Reference

https://go.dev/doc/
https://github.com/syyongx/php2go

·END·

gotools's People

Contributors

wangyongtao avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.