From b0bb22aa9c9f1d5b2e582e58bf20c6856feb87ec Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Sun, 15 Aug 2021 12:29:03 -0300 Subject: go fmt --- tripcode.go | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'tripcode.go') diff --git a/tripcode.go b/tripcode.go index 7e19cf0..b567bf0 100644 --- a/tripcode.go +++ b/tripcode.go @@ -1,15 +1,15 @@ package main import ( - "golang.org/x/text/encoding/japanese" - "golang.org/x/text/transform" - "github.com/simia-tech/crypt" - "strings" "bytes" - "regexp" "database/sql" _ "github.com/lib/pq" - "net/http" + "github.com/simia-tech/crypt" + "golang.org/x/text/encoding/japanese" + "golang.org/x/text/transform" + "net/http" + "regexp" + "strings" ) const SaltTable = "" + @@ -22,7 +22,6 @@ const SaltTable = "" + "................................" + "................................" - func TripCode(pass string) string { pass = TripCodeConvert(pass) @@ -32,25 +31,25 @@ func TripCode(pass string) string { s := []rune(pass + "H..")[1:3] for i, r := range s { - salt[i] = rune(SaltTable[r % 256]) + salt[i] = rune(SaltTable[r%256]) } - enc, err := crypt.Crypt(pass, "$1$" + string(salt[:])) - + enc, err := crypt.Crypt(pass, "$1$"+string(salt[:])) + CheckError(err, "crypt broke") - - return enc[len(enc) - 10 : len(enc)] + + return enc[len(enc)-10 : len(enc)] } func TripCodeSecure(pass string) string { pass = TripCodeConvert(pass) - enc, err := crypt.Crypt(pass, "$1$" + Salt) - + enc, err := crypt.Crypt(pass, "$1$"+Salt) + CheckError(err, "crypt secure broke") - - return enc[len(enc) - 10 : len(enc)] + + return enc[len(enc)-10 : len(enc)] } func TripCodeConvert(str string) string { @@ -76,30 +75,30 @@ func CreateNameTripCode(r *http.Request, db *sql.DB) (string, string) { if tripSecure.MatchString(input) { chunck := tripSecure.FindString(input) chunck = strings.Replace(chunck, "##", "", 1) - - ce := regexp.MustCompile(`(?i)Admin`) + + ce := regexp.MustCompile(`(?i)Admin`) admin := ce.MatchString(chunck) board, modcred := GetPasswordFromSession(r) - - if(admin && HasAuth(db, modcred, board)) { + + if admin && HasAuth(db, modcred, board) { return tripSecure.ReplaceAllString(input, ""), "#Admin" } hash := TripCodeSecure(chunck) return tripSecure.ReplaceAllString(input, ""), "!!" + hash - } - + } + trip := regexp.MustCompile("#(.+)?") if trip.MatchString(input) { chunck := trip.FindString(input) chunck = strings.Replace(chunck, "#", "", 1) - - ce := regexp.MustCompile(`(?i)Admin`) + + ce := regexp.MustCompile(`(?i)Admin`) admin := ce.MatchString(chunck) board, modcred := GetPasswordFromSession(r) - - if(admin && HasAuth(db, modcred, board)) { + + if admin && HasAuth(db, modcred, board) { return trip.ReplaceAllString(input, ""), "#Admin" } -- cgit v1.2.3