mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
move api package to sub folder
This commit is contained in:
parent
ff29c83d56
commit
ff1be787f2
23 changed files with 61 additions and 61 deletions
25
api/misc.go
Normal file
25
api/misc.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue