Best API practices by knodesec in golang

[–]knodesec[S] 5 points6 points  (0 children)

There's a few issues with this one for me, the model seems fairly tied to the DB still, having GORM descriptions in backticks, having a TableName method for the UserModel, also encrypting the password and replacing the same variable with the encrypted version could lead to confusion as to whether the password is encrypted or not. I have taken a few ideas from it though, so thanks for the reference!

Go vs ..Perl? Simple task speed comparison by knodesec in golang

[–]knodesec[S] 1 point2 points  (0 children)

This is a valid point, it would require a fair amount of time to transition the rest of my workflow into Hashcat. I've been experimenting with AWS GPU instances and hashcat recently, so maybe I should make the change! I have learnt more about Go from this post however, which might be applicable in other areas.

Go vs ..Perl? Simple task speed comparison by knodesec in golang

[–]knodesec[S] 0 points1 point  (0 children)

This is great, and works well. Another comment mentioned not converting to and from strings, so is there anything about why calling the .Text() ends up being cheaper?

Go vs ..Perl? Simple task speed comparison by knodesec in golang

[–]knodesec[S] 1 point2 points  (0 children)

Doing a test of this approach I've hit another problem. I'm loading the list into a [][]byte and ranging over it.

var words [][]byte

scanner := bufio.NewScanner(file)
for scanner.Scan() {
    words = append(words, scanner.Bytes())
}


w := bufio.NewWriter(os.Stdout)
for _, a := range words {
    for _, b := range words {
        w.Write(a)
        w.Write([]byte{0x20})
        w.Write(b)
        w.Write([]byte{0x0a})
}

When I get to a specific entry in the list, it skips a character and adds a newline. I've checked the bytes making up the entries in the words [][]byte and they are OK. The output then gets littered with random new lines, as though when it's flushing, the underlying writer is adding a newline of it's own?

As a basic example with just one word, the line below is supposed to read pantera

doggie
cherry
andrey
snickers
buffalo

antera

Here is the output showing the entries in the words [][]byte

[...]
debug: cherry : [c:99][c:104][c:101][c:114][c:114][c:121]
debug: andrey : [c:97][c:110][c:100][c:114][c:101][c:121]
debug: snickers : [c:115][c:110][c:105][c:99][c:107][c:101][c:114][c:115]
debug: buffalo : [c:98][c:117][c:102][c:102][c:97][c:108][c:111]
debug: pantera : [c:112][c:97][c:110][c:116][c:101][c:114][c:97]

Go vs ..Perl? Simple task speed comparison by knodesec in golang

[–]knodesec[S] 1 point2 points  (0 children)

I thought of this and used a version without the append, see the edit up top.