date: 12/09/2024
language: Go
utility: one time key generation
This little script is pretty darn simple, it takes the unix time in nano seconds and then parses it through a HASH256 encryption
the other aspect of the keygen is up to you, you can add a javascript function to autodelete the key once its used or after a certain amount of time for example
this is just a small proof of concept for a simple high security keygen tbh.
go.sum and go.mod are also required.
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"os"
"strconv"
"time"
)
func shaHashing(input int64) string {
plainText := []byte(strconv.FormatInt(input, 10))
sha256Hash := sha256.Sum256(plainText)
return hex.EncodeToString(sha256Hash[:])
}
func main() {
currentTime := time.Now().UnixNano()
hash := shaHashing(currentTime)
fmt.Println("SHA-256 Hash:", hash)
file, errs := os.Create("key.txt")
if errs != nil {
fmt.Println("Failed to create file:", errs)
return
}
defer file.Close()
_, errs = file.WriteString(hash)
if errs != nil {
fmt.Println("Failed to write to file:", errs)
return
}
fmt.Println("Wrote to file 'key.txt'.")
}