MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Verify

Method Verify

internal/waf/captcha_generator.go:47–66  ·  view source on GitHub ↗

Verify user input

(id string, digits string)

Source from the content-addressed store, hash-verified

45
46// Verify user input
47func (this *CaptchaGenerator) Verify(id string, digits string) bool {
48 var countDigits = len(digits)
49 if countDigits == 0 {
50 return false
51 }
52 var value = this.store.Get(id, true)
53 if len(value) != countDigits {
54 return false
55 }
56
57 var nb = make([]byte, countDigits)
58 for i := 0; i < countDigits; i++ {
59 var d = digits[i]
60 if d >= '0' && d <= '9' {
61 nb[i] = d - '0'
62 }
63 }
64
65 return bytes.Equal(nb, value)
66}
67
68// Get captcha data
69func (this *CaptchaGenerator) Get(id string) []byte {

Calls 1

GetMethod · 0.45