当前位置:网站首页>Get the current time in go language, and the simple implementation of MD5, HMAC, SHA1 algorithms
Get the current time in go language, and the simple implementation of MD5, HMAC, SHA1 algorithms
2022-07-24 20:19:00 【A small coal ball eating watermelon】
package main
import (
"crypto/hmac"
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"fmt"
"strconv"
"time"
)
func main() {
curTime := strconv.FormatInt(time.Now().Unix(), 10)
fmt.Println(curTime)
fmt.Println(Md5("hello"))
fmt.Println(Hmac("key2", "hello"))
fmt.Println(Sha1("hello", "file_"+curTime))
}
func Md5(data string) string {
md5 := md5.New()
md5.Write([]byte(data))
md5Data := md5.Sum([]byte(""))
return hex.EncodeToString(md5Data)
}
func Hmac(key, data string) string {
hmac := hmac.New(md5.New, []byte(key))
hmac.Write([]byte(data))
return hex.EncodeToString(hmac.Sum([]byte("")))
}
func Sha1(data1 string, data2 string) string {
sha1 := sha1.New()
sha1.Write([]byte(data1))
sha1.Write([]byte(data2))
return hex.EncodeToString(sha1.Sum([]byte("")))
}
边栏推荐
- Batch download files from the server to the local
- 2019 Hangzhou Electric Multi School Game 9 6684 Rikka with game [game question]
- Mysql8 doesn't seem to support MyISAM partition tables. Does polardb-x support MyISAM partition tables?
- Hcip early summary
- Luogu - p1616 crazy herb picking
- Flink Window&Time 原理
- Mass modify attribute values in objects in JS
- 02 | environment preparation: how to install and configure a basic PHP development environment under windows?
- Maya coffee machine modeling
- Understand the domestic open source Magnolia license series agreement in simple terms
猜你喜欢
![[training Day10] linear [mathematics] [thinking]](/img/bf/0082dbe88c579bbb7adc014c60a0be.png)
[training Day10] linear [mathematics] [thinking]

Usage and introduction of MySQL binlog

Home Assistant中接入博联WiFi智能遥控

Getting started with COM programming 1- creating projects and writing interfaces
![[training Day6] triangle [mathematics] [violence]](/img/57/d603886c202de7d46ea03487b633f5.png)
[training Day6] triangle [mathematics] [violence]

147-利用路由元信息设置是否缓存——include和exclude使用——activated和deactivated的使用
![[msp430g2553] graphical development notes (2) system clock and low power consumption mode](/img/4e/c08288c3804d3f1bcd5ff2826f7546.png)
[msp430g2553] graphical development notes (2) system clock and low power consumption mode

Working principle of envy of istio I

【LeetCode】1184. 公交站间的距离

Modbus communication protocol specification (Chinese) sharing
随机推荐
Introduction and advanced tutorial of Albert duilib
Make Huawei router into FTP server (realize upload and download function)
Apache atlas version 2.2 installation
Huawei set up login with account and password
[German flavor] safety: how to provide more protection for pedestrians
Getting started with COM programming 1- creating projects and writing interfaces
Qt| control qscrollbar display position
Covid-19-20 - basic method of network segmentation based on vnet3d
Redisgraph graphic database multi activity design scheme
Redis basic knowledge, application scenarios, cluster installation
English translation Chinese common dirty words
Introduction to WDK development 1- basic environment construction and the first driver (VS2010)
Login Huawei device in SSH mode
Read the registry through the ATL library clegkey (simple and convenient)
[trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
[training Day8] tent [mathematics] [DP]
Safe way -- Analysis of single pipe reverse connection back door
Leetcode 48 rotating image (horizontal + main diagonal), leetcode 221 maximum square (dynamic programming DP indicates the answer value with ij as the lower right corner), leetcode 240 searching two-d
Solve the problem of error l6218e undefined symbol XXX
[training Day10] tree [interval DP]