Skip to content

Instantly share code, notes, and snippets.

@csandanov
Last active May 3, 2024 16:55
Show Gist options
  • Save csandanov/cd9b01f38003b2eea3466b51394a01e0 to your computer and use it in GitHub Desktop.
Save csandanov/cd9b01f38003b2eea3466b51394a01e0 to your computer and use it in GitHub Desktop.
Generate solr password (sha256+salt) in golang
// https://go.dev/play/p/luLFCOgkos9
package main
import (
"crypto/sha256"
"encoding/base64"
"fmt"
)
func main() {
pass := "password"
salt := "salt"
hasher := sha256.New()
hasher.Write([]byte(fmt.Sprintf("%s%s", pass, salt)))
res := hasher.Sum(nil)
hasher.Reset()
hasher.Write(res)
fmt.Printf("%s %s\n", base64.StdEncoding.EncodeToString(hasher.Sum(nil)), base64.StdEncoding.EncodeToString([]byte(salt)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment