Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flxxyz/hash
golang简化加密类库
https://github.com/flxxyz/hash
go golang-library hash
Last synced: 4 days ago
JSON representation
golang简化加密类库
- Host: GitHub
- URL: https://github.com/flxxyz/hash
- Owner: flxxyz
- License: mit
- Created: 2019-06-21T09:56:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-21T10:25:58.000Z (over 5 years ago)
- Last Synced: 2024-06-20T17:31:43.310Z (5 months ago)
- Topics: go, golang-library, hash
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hash
golang简化加密类库## 依赖要求
没有## 安装
使用`go`命令获取类库```bash
go get github.com/flxxyz/hash
```## 例子
```go
package mainimport (
"fmt"
"github.com/flxxyz/hash"
)func main() {
//sha1编码
hashValue := hash.SHA1("0")
fmt.Printf("[sha1] 0 => %s", hashValue)//sha256编码
hashValue = hash.SHA256("0")
fmt.Printf("[sha256] 0 => %s", hashValue)//sha512编码
hashValue = hash.SHA512("0")
fmt.Printf("[sha512] 0 => %s", hashValue)//md5编码
hashValue = hash.MD5("0")
fmt.Printf("[md5] 0 => %s", hashValue)//hmac
{
data := "0"
key := "1234567890"//以md5规则生成
hashValue = hash.HMAC("md5", key, data)
fmt.Printf("[md5] \"%s\" => %s", data, hashValue)//以sha1规则生成
hashValue = hash.HMAC("sha1", key, data)
fmt.Printf("[sha1] \"%s\" => %s", data, hashValue)//以sha256规则生成
hashValue = hash.HMAC("sha256", key, data)
fmt.Printf("[sha256] \"%s\" => %s", data, hashValue)//以sha512规则生成
hashValue = hash.HMAC("sha512", key, data)
fmt.Printf("[sha512] \"%s\" => %s", data, hashValue)
}//base64
{
//base64编码
encodeStr := "hello world"
hashValue = hash.Base64Encode(encodeStr)
fmt.Printf("[base64] encode \"%s\" => %s", encodeStr, hashValue)//base64解码
decodeStr := "aGVsbG8gd29ybGQ="
hashValue = hash.Base64Decode(decodeStr)
fmt.Printf("[sha512] \"%s\" => %s", decodeStr, hashValue)
}
}
```## 文档
[文档点这里](http://godoc.org/github.com/flxxyz/hash)## 版权
hash包在MIT License下发布。有关详细信息,请参阅LICENSE。