Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/dchest/captcha
/ functions
Functions
91 in github.com/dchest/captcha
⨍
Functions
91
◇
Types & classes
8
↓ 13 callers
Method
Int
Int returns a pseudorandom int in range [from, to].
siprng.go:271
↓ 13 callers
Function
RandomDigits
RandomDigits returns a byte slice of the given length containing pseudorandom numbers in range 0-9. The slice can be used as a captcha solution.
random.go:59
↓ 13 callers
Method
Set
Set sets the digits for the captcha id.
store.go:22
↓ 13 callers
Method
Write
(b []byte)
image_test.go:13
↓ 11 callers
Method
Get
Get returns stored digits for the captcha id. Clear indicates whether the captcha must be deleted from the store.
store.go:26
↓ 9 callers
Method
Float
Float returns a pseudorandom float64 in range [from, to].
siprng.go:276
↓ 7 callers
Method
Intn
(n int)
siprng.go:234
↓ 7 callers
Method
Uint64
Uint64 returns a new pseudorandom uint64.
siprng.go:200
↓ 7 callers
Function
randomId
randomId returns a new random id string.
random.go:102
↓ 6 callers
Method
Bytes
(n int)
siprng.go:206
↓ 5 callers
Function
New
New creates a new captcha with the standard length, saves it in the internal storage and returns its id.
captcha.go:79
↓ 5 callers
Function
NewMemoryStore
NewMemoryStore returns a new standard memory store for captchas with the given collection threshold and expiration time (duration). The returned store
store.go:53
↓ 5 callers
Method
Seed
Seed sets a new secret seed for PRNG.
siprng.go:193
↓ 5 callers
Method
drawHorizLine
(fromX, toX, y int, colorIdx uint8)
image.go:141
↓ 4 callers
Function
NewAudio
NewAudio returns a new audio captcha with the given digits, where each digit must be in range 0-9. Digits are pronounced in the given language. If the
audio.go:33
↓ 4 callers
Function
NewImage
NewImage returns a new captcha image of the given width and height with the given digits, where each digit must be in range 0-9.
image.go:36
↓ 4 callers
Method
WriteTo
WriteTo writes captcha image in PNG format into the given writer.
image.go:99
↓ 3 callers
Method
Int63
()
siprng.go:222
↓ 3 callers
Function
Verify
Verify returns true if the given digits are the ones that were used to create the given captcha id. The function deletes the captcha with the given i
captcha.go:134
↓ 3 callers
Function
changeSpeed
changeSpeed returns new PCM bytes from the bytes with the speed and pitch changed to the given value that must be in range [0, x].
audio.go:205
↓ 3 callers
Method
collect
()
store.go:98
↓ 3 callers
Method
drawCircle
(x, y, radius int, colorIdx uint8)
image.go:147
↓ 2 callers
Method
Int31
()
siprng.go:230
↓ 2 callers
Function
Reload
Reload generates and remembers new digits for the given captcha id. This function returns false if there is no captcha with the given id. After call
captcha.go:97
↓ 2 callers
Function
deriveSeed
deriveSeed returns a 16-byte PRNG seed from rngKey, purpose, id and digits. Same purpose, id and digits will result in the same derived seed for this
random.go:44
↓ 2 callers
Function
mixSound
mixSound mixes src into dst. Dst must have length equal to or greater than src length.
audio.go:172
↓ 2 callers
Function
randomBytesMod
randomBytesMod returns a byte slice of the given length, where each byte is a random number modulo mod.
random.go:74
↓ 2 callers
Function
setSoundLevel
(a []byte, level float64)
audio.go:184
↓ 2 callers
Function
siphash
siphash implements SipHash-2-4, accepting a uint64 as a message.
siprng.go:16
↓ 2 callers
Function
writeFileRep
(pcm io.Writer, name, prefix string)
capgensounds/main.go:45
↓ 1 callers
Method
Float64
()
siprng.go:268
↓ 1 callers
Method
Int31n
(n int32)
siprng.go:256
↓ 1 callers
Method
Int63n
(n int64)
siprng.go:244
↓ 1 callers
Function
NewLen
NewLen is just like New, but accepts length of a captcha solution as the argument.
captcha.go:85
↓ 1 callers
Function
Server
Server returns a handler that serves HTTP requests with image or audio representations of captchas. Image dimensions are accepted as arguments. The se
server.go:42
↓ 1 callers
Method
Uint32
()
siprng.go:226
↓ 1 callers
Function
VerifyString
VerifyString is like Verify, but accepts a string of digits. It removes spaces and commas from the string, but any other characters, apart from digit
captcha.go:148
↓ 1 callers
Function
WriteAudio
WriteAudio writes WAV-encoded audio representation of the captcha with the given id and the given language. If there are no sounds for the given langu
captcha.go:120
↓ 1 callers
Function
WriteImage
WriteImage writes PNG-encoded image representation of the captcha with the given id. The image will have the given width and height.
captcha.go:108
↓ 1 callers
Method
WriteTo
WriteTo writes captcha audio in WAVE format into the given io.Writer, and returns the number of bytes written and an error if any.
audio.go:85
↓ 1 callers
Method
calculateSizes
(width, height, ncount int)
image.go:104
↓ 1 callers
Method
distort
(amplude float64, period float64)
image.go:218
↓ 1 callers
Method
drawDigit
(digit []byte, x, y int)
image.go:201
↓ 1 callers
Method
encodedPNG
encodedPNG encodes an image to PNG and returns the result as a byte slice.
image.go:90
↓ 1 callers
Method
fillWithCircles
(n, maxradius int)
image.go:174
↓ 1 callers
Method
getRandomPalette
()
image.go:69
↓ 1 callers
Method
longestDigitSndLen
()
audio.go:144
↓ 1 callers
Method
makeBackgroundSound
(length int)
audio.go:126
↓ 1 callers
Function
makeSilence
(length int)
audio.go:217
↓ 1 callers
Method
makeWhiteNoise
(length int, level uint8)
audio.go:159
↓ 1 callers
Function
max3
(x, y, z uint8)
image.go:262
↓ 1 callers
Function
min3
(x, y, z uint8)
image.go:251
↓ 1 callers
Method
randomBrightness
(c color.RGBA, max uint8)
image.go:236
↓ 1 callers
Function
randomBytes
randomBytes returns a byte slice of the given length read from CSPRNG.
random.go:64
↓ 1 callers
Method
randomSpeed
(b []byte)
audio.go:154
↓ 1 callers
Method
randomizedDigitSound
(n byte)
audio.go:138
↓ 1 callers
Function
reversedSound
(a []byte)
audio.go:225
↓ 1 callers
Method
serve
(w http.ResponseWriter, r *http.Request, id, ext, lang string, download bool)
server.go:46
↓ 1 callers
Method
strikeThrough
()
image.go:184
↓ 1 callers
Function
usage
()
capgen/main.go:26
↓ 1 callers
Function
writeDigitSounds
(pcm io.Writer, lang string)
capgensounds/main.go:59
↓ 1 callers
Function
writeSingle
(pcm io.Writer, name string)
capgensounds/main.go:53
↓ 1 callers
Function
writeVar
(w io.Writer, b []byte, prefix string)
capgensounds/main.go:23
Function
BenchmarkAudioWriteTo
(b *testing.B)
audio_test.go:22
Function
BenchmarkImageWriteTo
(b *testing.B)
image_test.go:28
Function
BenchmarkNewAudio
(b *testing.B)
audio_test.go:12
Function
BenchmarkNewImage
(b *testing.B)
image_test.go:18
Function
BenchmarkSetCollect
(b *testing.B)
store_test.go:64
Function
BenchmarkSiprng
(b *testing.B)
siprng_test.go:48
Method
EncodedLen
EncodedLen returns the length of WAV-encoded audio captcha.
audio.go:122
Method
Get
(id string, clear bool)
store.go:75
Method
ServeHTTP
(w http.ResponseWriter, r *http.Request)
server.go:70
Method
Set
(id string, digits []byte)
store.go:62
Function
SetCustomStore
SetCustomStore sets custom storage for captchas, replacing the default memory store. This function must be called before generating any captchas.
captcha.go:73
Function
TestCollect
(t *testing.T)
store_test.go:38
Function
TestGetClear
(t *testing.T)
store_test.go:23
Function
TestNew
(t *testing.T)
captcha_test.go:12
Function
TestRandomDigits
(t *testing.T)
captcha_test.go:41
Function
TestReload
(t *testing.T)
captcha_test.go:31
Function
TestSetGet
(t *testing.T)
store_test.go:12
Function
TestSiphash
(t *testing.T)
siprng_test.go:8
Function
TestSiprng
(t *testing.T)
siprng_test.go:16
Function
TestSiprngBytes
(t *testing.T)
siprng_test.go:30
Function
TestVerify
(t *testing.T)
captcha_test.go:19
Function
init
()
random.go:25
Function
init
()
audio.go:18
Function
main
()
capexample/main.go:44
Function
main
()
capgensounds/main.go:69
Function
main
()
capgen/main.go:31
Function
processFormHandler
(w http.ResponseWriter, r *http.Request)
capexample/main.go:34
Function
showFormHandler
(w http.ResponseWriter, r *http.Request)
capexample/main.go:19