mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
https://github.com/XTLS/Xray-core/issues/3547#issuecomment-3549896520 https://github.com/XTLS/Xray-core/issues/2635#issuecomment-3570871754
25 lines
421 B
Go
25 lines
421 B
Go
package padding
|
|
|
|
import (
|
|
"math/rand"
|
|
)
|
|
|
|
const (
|
|
paddingChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
)
|
|
|
|
// padding specifies a half-open range [Min, Max).
|
|
type Padding struct {
|
|
Min int
|
|
Max int
|
|
}
|
|
|
|
func (p Padding) String() string {
|
|
n := p.Min + rand.Intn(p.Max-p.Min)
|
|
bs := make([]byte, n)
|
|
for i := range bs {
|
|
bs[i] = paddingChars[rand.Intn(len(paddingChars))]
|
|
}
|
|
return string(bs)
|
|
}
|