Testing

Run Settings
LanguageGo
Language Version
Run Command
package main import ( "fmt" "strconv" "math/rand" "crypto/sha256" "time" ) func GenerateCode() string { // Get the current time in nanoseconds. now := time.Now().UnixNano() // Generate a random number using the math/rand function. rand.Seed(time.Now().UnixNano()) randNum := rand.Int63() % 1000000 // Combine the current time, the random number, and a hash of the current time // to create the OTP. hash := sha256.New() hash.Write([]byte(strconv.FormatInt(now, 10))) otp := strconv.FormatInt(now, 10)[:6] + strconv.FormatInt(randNum, 10)[:6] + fmt.Sprint(hash.Sum(nil)[:6]) // Return the OTP. return otp } func main() { fmt.Println(GenerateCode()) }
Editor Settings
Theme
Key bindings
Full width
Lines