Created
July 1, 2016 16:50
-
-
Save craftbyte/c31733b67721d085c3f26091e78072e4 to your computer and use it in GitHub Desktop.
Pass generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/rand" | |
"encoding/hex" | |
"fmt" | |
"github.com/howeyc/gopass" | |
"golang.org/x/crypto/scrypt" | |
"io" | |
"math" | |
) | |
func main() { | |
var scryptWorkFactor = int(math.Pow(2, 15)) | |
var scryptBlockSize = 8 | |
var scryptParallization = 1 | |
fmt.Println("Please enter your password (for security reasons, characters will be hidden)") | |
pass, _ := gopass.GetPasswd() | |
salt1 := make([]byte, 32) | |
salt2 := make([]byte, 32) | |
if _, err := io.ReadFull(rand.Reader, salt1); err != nil { | |
panic(err) | |
} | |
if _, err := io.ReadFull(rand.Reader, salt2); err != nil { | |
panic(err) | |
} | |
hash1, _ := scrypt.Key([]byte(pass), salt1, scryptWorkFactor, scryptBlockSize, scryptParallization, 32) | |
hash2, _ := scrypt.Key([]byte(pass), salt2, scryptWorkFactor, scryptBlockSize, scryptParallization, 32) | |
fmt.Println("Insert into users:") | |
fmt.Println("hash", hex.EncodeToString(hash2)) | |
fmt.Println("salt", hex.EncodeToString(salt1)) | |
fmt.Println("Insert into hashes:") | |
fmt.Println("hash", hex.EncodeToString(hash1)) | |
fmt.Println("salt", hex.EncodeToString(salt2)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment