[fix] SetCharacters
This commit is contained in:
parent
8fb5effbba
commit
0af9fc6452
@ -23,7 +23,7 @@ func init() {
|
|||||||
func GenerateProjectSecret(key, secret string) ([]byte, error) {
|
func GenerateProjectSecret(key, secret string) ([]byte, error) {
|
||||||
appSecret := lo.FindUniques([]byte(secret))
|
appSecret := lo.FindUniques([]byte(secret))
|
||||||
|
|
||||||
if len(appSecret) != 62 {
|
if len(secret) != 62 {
|
||||||
return nil, fmt.Errorf("Invalid secret")
|
return nil, fmt.Errorf("Invalid secret")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ func GenerateProjectSecret(key, secret string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetCharacters(secret string) error {
|
func SetCharacters(secret string) error {
|
||||||
if len(secret) != 64 {
|
if len(secret) != 62 {
|
||||||
return fmt.Errorf("encoding alphabet is not 62-bytes long")
|
return fmt.Errorf("encoding alphabet is not 62-bytes long")
|
||||||
}
|
}
|
||||||
bs62 = base62.NewEncoding(secret)
|
bs62 = base62.NewEncoding(secret)
|
||||||
|
@ -41,7 +41,7 @@ func TestGenerateProjectSecret(t *testing.T) {
|
|||||||
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK 加密后
|
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK 加密后
|
||||||
|
|
||||||
// PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK
|
// PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK
|
||||||
res, _ := GenerateProjectSecret("demo", "PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK")
|
res, _ := GenerateProjectSecret("demo", "PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK")
|
||||||
t.Log(string(res))
|
t.Log(string(res))
|
||||||
|
|
||||||
res1, _ := GenerateProjectSecret("demo", "PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK")
|
res1, _ := GenerateProjectSecret("demo", "PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK")
|
||||||
@ -50,3 +50,8 @@ func TestGenerateProjectSecret(t *testing.T) {
|
|||||||
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK
|
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK
|
||||||
// PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK
|
// PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAlphabetEncode(t *testing.T) {
|
||||||
|
t.Log(SetCharacters("PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK"))
|
||||||
|
t.Log(Encode(map[string]any{"isDebug": 1}))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user