Files
2026-11-06 10:40:07 +08:00

19 lines
367 B
Go

package generator
import (
"crypto/rand"
"encoding/base64"
"errors"
)
func GenShadowsocksPassword(bits int) (string, error) {
if bits%8 != 0 {
return "", errors.New("bits must be multiple of 8")
}
password := make([]byte, bits/8)
if _, err := rand.Read(password); err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(password), nil
}