mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-09 17:48:20 +00:00
fix lint
This commit is contained in:
parent
0538e86ddd
commit
28e2ccf7e4
2 changed files with 9 additions and 22 deletions
|
@ -146,10 +146,7 @@ func (c *Client) Login(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// Validate that this Publickey that the Server gave us actually Matches our Privatekey
|
||||
randomString, err := randStringBytesRmndr(50)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Generating Random String as PublicKey Validation Message: %w", err)
|
||||
}
|
||||
randomString := randStringBytesRmndr(50)
|
||||
armor, err := helper.EncryptMessageArmored(user.GPGKey.ArmoredKey, randomString)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Encryping PublicKey Validation Message: %w", err)
|
||||
|
|
26
api/misc.go
26
api/misc.go
|
@ -1,25 +1,15 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func randStringBytesRmndr(length int) (string, error) {
|
||||
result := ""
|
||||
for {
|
||||
if len(result) >= length {
|
||||
return result, nil
|
||||
}
|
||||
num, err := rand.Int(rand.Reader, big.NewInt(int64(127)))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
n := num.Int64()
|
||||
// Make sure that the number/byte/letter is inside
|
||||
// the range of printable ASCII characters (excluding space and DEL)
|
||||
if n > 32 && n < 127 {
|
||||
result += string(n)
|
||||
}
|
||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
func randStringBytesRmndr(length int) string {
|
||||
b := make([]byte, length)
|
||||
for i := range b {
|
||||
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue