Skip to content

Instantly share code, notes, and snippets.

@froyobin
Last active March 28, 2020 10:34
Show Gist options
  • Save froyobin/8cbcb44bbee29f541d10aa61146b0f6d to your computer and use it in GitHub Desktop.
Save froyobin/8cbcb44bbee29f541d10aa61146b0f6d to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"crypto/sha256"
"fmt"
"math"
"time"
)
func main() {
//time differnece
timeNow := time.Now()
timeLater := timeNow.Add(time.Second * 16 * 60)
delta := math.Ceil(timeLater.Sub(time.Now()).Minutes() / 5)
fmt.Printf("------->%v\n", delta)
// hash
str := timeNow.String()
fmt.Printf("----->%v\n", timeNow.UTC())
sum := sha256.Sum256([]byte(str))
fmt.Printf("%x", sum)
// combine keys
var keyBuffer bytes.Buffer
key1 := []byte("hello")
key2 := []byte("+word")
key3 := []byte("+word1")
key4 := []byte("+word2")
keyBuffer.Write(key1)
keyBuffer.Write(key2)
keyBuffer.Write(key3)
keyBuffer.Write(key4)
combinedKey := keyBuffer.Bytes()
fmt.Printf("------>%v\n", string(combinedKey))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment