Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/dchest/captcha
/ functions
Functions
74 in github.com/dchest/captcha
⨍
Functions
74
◇
Types & classes
7
↓ 11 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:27
↓ 10 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
↓ 8 callers
Method
Set
Set sets the digits for the captcha id.
store.go:22
↓ 6 callers
Function
rndf
rndf returns a non-crypto pseudorandom float64 in range [from, to].
random.go:78
↓ 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
Function
rnd
rnd returns a non-crypto pseudorandom int in range [from, to].
random.go:73
↓ 4 callers
Function
NewAudio
NewImage 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:36
↓ 4 callers
Method
WriteTo
BUG(dchest): While Image conforms to io.WriterTo interface, its WriteTo method returns 0 instead of the actual bytes written because png.Encode doesn'
image.go:88
↓ 3 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
↓ 3 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:54
↓ 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:188
↓ 3 callers
Method
collect
()
store.go:98
↓ 3 callers
Method
drawCircle
(x, y, radius int, colorIdx uint8)
image.go:132
↓ 3 callers
Function
randomId
randomId returns a new random id string.
random.go:64
↓ 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
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
↓ 2 callers
Method
Write
(b []byte)
image_test.go:13
↓ 2 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:84
↓ 2 callers
Function
mixSound
mixSound mixes src into dst. Dst must have length equal to or greater than src length.
audio.go:155
↓ 2 callers
Function
randomBytes
randomBytes returns a byte slice of the given length read from CSPRNG.
random.go:32
↓ 2 callers
Function
randomBytesMod
randomBytesMod returns a byte slice of the given length, where each byte is a random number modulo mod.
random.go:42
↓ 2 callers
Function
setSoundLevel
(a []byte, level float64)
audio.go:167
↓ 2 callers
Function
writeFileRep
(pcm io.Writer, name, prefix string)
capgensounds/main.go:45
↓ 1 callers
Method
EncodedLen
EncodedLen returns the length of WAV-encoded audio captcha.
audio.go:121
↓ 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
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
calculateSizes
(width, height, ncount int)
image.go:92
↓ 1 callers
Method
distort
(amplude float64, period float64)
image.go:203
↓ 1 callers
Method
drawDigit
(digit []byte, x, y int)
image.go:186
↓ 1 callers
Method
drawHorizLine
(fromX, toX, y int, colorIdx uint8)
image.go:126
↓ 1 callers
Method
fillWithCircles
(n, maxradius int)
image.go:159
↓ 1 callers
Method
longestDigitSndLen
()
audio.go:143
↓ 1 callers
Method
makeBackgroundSound
(length int)
audio.go:125
↓ 1 callers
Function
makeSilence
(length int)
audio.go:205
↓ 1 callers
Function
makeWhiteNoise
(length int, level uint8)
audio.go:213
↓ 1 callers
Function
max3
(x, y, z uint8)
image.go:247
↓ 1 callers
Function
min3
(x, y, z uint8)
image.go:236
↓ 1 callers
Function
randomBrightness
(c color.RGBA, max uint8)
image.go:221
↓ 1 callers
Function
randomPalette
()
image.go:33
↓ 1 callers
Function
randomSpeed
(a []byte)
audio.go:200
↓ 1 callers
Method
randomizedDigitSound
(n byte)
audio.go:137
↓ 1 callers
Function
reversedSound
(a []byte)
audio.go:224
↓ 1 callers
Method
serve
(w http.ResponseWriter, id, ext string, lang string, download bool)
server.go:45
↓ 1 callers
Method
strikeThrough
()
image.go:169
↓ 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:21
Function
BenchmarkImageWriteTo
(b *testing.B)
image_test.go:27
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:65
Method
Get
(id string, clear bool)
store.go:75
Method
ServeHTTP
(w http.ResponseWriter, r *http.Request)
server.go:74
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:41
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
TestVerify
(t *testing.T)
captcha_test.go:19
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
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
Function
init
()
random.go:20
Function
init
()
audio.go:22
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