dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit ed851a939d644b994430d7e9dd03294345e46bbe
parent 31970c7e83de669785996b4c193307b3fb779632
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon,  3 Apr 2023 15:12:44 -0700

put captcha back to numbers only

Diffstat:
Mpkg/captcha/captcha.go | 6++++--
Mpkg/captcha/image.go | 6+++---
Mpkg/web/public/views/pages/captcha-help.gohtml | 1-
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/pkg/captcha/captcha.go b/pkg/captcha/captcha.go @@ -58,6 +58,8 @@ import ( ) const ( + //alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" + ALPHABET = "0123456789" // The number of captchas created that triggers garbage collection used // by default store. CollectNum = 100 @@ -92,9 +94,9 @@ func randomId(rnd *rand.Rand) string { // solution. func randomAnswer(length int, rnd *rand.Rand) string { out := make([]rune, length) - alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" + alphabet := ALPHABET for i := 0; i < length; i++ { - out[i] = rune(alphabet[rnd.Intn(32)]) + out[i] = rune(alphabet[rnd.Intn(len(alphabet))]) } return string(out) } diff --git a/pkg/captcha/image.go b/pkg/captcha/image.go @@ -395,14 +395,14 @@ func NewImage(answer string, difficulty int64, rnd *rand.Rand, isHelpImg bool) * m.thirdPath = m.generateSemiValidPath(usedCoordsMap) updateUsedCoordsMap(m.thirdPath, usedCoordsMap) - alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" + alphabet := ALPHABET // Generate all numbers m.numbersMatrix = make([][]Number, 0) for row := 0; row < m.nbNumRows; row++ { numbers := make([]Number, 0) for col := 0; col < m.nbNumCols; col++ { - d := m.RandInt(0, 31) + d := m.RandInt(0, len(alphabet)-1) opacity := uint8(255) if m.renderHelpImg { opacity = 100 @@ -452,7 +452,7 @@ func loadFontFaces() (out []font1.Face) { loadFF("font/Lato-Regular.ttf", 25) loadFF("font/JessicaGroovyBabyFINAL2.ttf", 25) loadFF("font/PineappleDelight.ttf", 25) - //loadFF("font/df66c.ttf", 20) + loadFF("font/df66c.ttf", 20) loadFF("font/agengsans.ttf", 30) return } diff --git a/pkg/web/public/views/pages/captcha-help.gohtml b/pkg/web/public/views/pages/captcha-help.gohtml @@ -14,7 +14,6 @@ You can start by finding a long line that doesn't have dashes in it, follow that line until you find the edge.<br /> Then go back and follow the line to the other edge and note the 6 numbers that the line cross path with.<br /> The direction is not important, both combination will work.<br /> - The possible characters are all capital letters A-Z and numbers from 2 to 7.<br /> </p> <img src="/public/img/captcha_example1.png" alt="" /> <img src="/public/img/captcha_example2.png" alt="" />