aboutsummaryrefslogtreecommitdiff
path: root/tripcode.go
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-08-15 12:29:03 -0300
committerKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-08-15 12:30:26 -0300
commitb0bb22aa9c9f1d5b2e582e58bf20c6856feb87ec (patch)
tree1107a5cbfd05f9b696d7ebacce9475f003db7a4c /tripcode.go
parent149f71db2d6e1b704ff2712393da5276a622d4dd (diff)
go fmt
Diffstat (limited to 'tripcode.go')
-rw-r--r--tripcode.go51
1 files changed, 25 insertions, 26 deletions
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"
}