当前位置:网站首页>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("")))
}
边栏推荐
- [trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
- The difference between delete, truncate and drop in MySQL
- 01 | 开篇词:手把手教你搭建一个博客网站
- [training Day6] triangle [mathematics] [violence]
- Choose the appropriate container runtime for kubernetes
- 870. Approximate number
- A circle is displayed and can be moved
- Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second
- Storage category
- Codeforces round 580 (Div. 2) c- almost equal [Law]
猜你喜欢
![[training Day8] series [matrix multiplication]](/img/00/06f7eb935bfd3c195e2e135197b4bd.png)
[training Day8] series [matrix multiplication]

Maya coffee machine modeling

Covid-19-20 - basic method of network segmentation based on vnet3d

Batch download files from the server to the local

Implementation of OA office system based on JSP

VLAN Technology

Basic idea of regularization
![[training Day8] tent [mathematics] [DP]](/img/d3/42869ed5bb7c9148d9fa7367a9af02.png)
[training Day8] tent [mathematics] [DP]

Talk about your transformation test development process

Leetcode 206 reverse linked list, 3 longest substring without repeated characters, 912 sorted array (fast row), the kth largest element in 215 array, 53 largest subarray and 152 product largest subarr
随机推荐
Pure C implementation -------- Nicolas theorem
1. Mx6u-alpha development board (key input experiment)
Setting up a dual machine debugging environment for drive development (vs2017)
【LeetCode】1184. 公交站间的距离
[training Day10] linear [mathematics] [thinking]
01 | opening words: teach you to build a blog website hand in hand
Choose the appropriate container runtime for kubernetes
Usage and introduction of MySQL binlog
Apache atlas version 2.2 installation
English grammar_ Demonstrative pronoun this / these / that / those
Implementation of OA office system based on JSP
From code farmer to great musician, you only need these music processing tools
Login Huawei device in SSH mode
What is IDE (integrated development environment)
Luogu - p1616 crazy herb picking
2019 Hangzhou Electric Multi School Game 7 6651 final exam [Law + thinking]
Connect the smart WiFi remote control in the home assistant
Getting started with COM programming 1- creating projects and writing interfaces
Xiaomi 12s ultra products are so powerful, but foreigners can't buy Lei Jun: first concentrate on the Chinese market
Pix2seq: Google brain proposes a unified interface for CV tasks!