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
Golang Convert String into Snake Case
Replace any non-alphanumeric character sequences with a dash using Regex
Example: How to use TeeReader from IO Package in Golang?
How to blur an image in Golang?
Replace numbers by zero from string
Golang import package inside package
How to Convert string to integer type in Go?
Example: Stack and Caller from RUNTIME package
How to concatenate two or more slices in Golang?
How to add and update elements in Map?