Generate a Keygen of 256 bits
Example
package main
import (
"crypto/rand"
"math/big"
"fmt"
"os"
"strconv"
)
const (
keyList string = "abcdefghijklmnopqrstuvwxyzABCDEFHFGHIJKLMNOPQRSTUVWXYZ1234567890"
)
func main() {
size := "256"
strLen, _ := strconv.Atoi(size)
filename := "keygen"
os.Create(filename)
f, _ := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0777)
for key := 1; key <= strLen; key++ {
res, _ := rand.Int(rand.Reader, big.NewInt(64))
keyGen := keyList[res.Int64()]
stringGen := fmt.Sprintf("%c", keyGen)
f.Write([]byte(stringGen))
}
f.Close()
}
Most Helpful This Week
Sierpinski Carpet in Go Programming Language
How to create Empty and Nil Slice?
Simple example of Map initialization in Go
Golang HTTP GET request with parameters
Various examples of Carbon date-time package in Golang
How to Unmarshal nested JSON structure?
Regular expression to validate the date format in "dd/mm/yyyy"
How to Convert string to float type in Go?
Sierpinski triangle in Go Programming Language
How to reads and decodes JSON values from an input stream?