use two more bytes for xid, but don't bother looking for dupes. 102 bits ought to be enough for anyone
Ted Unangst tedu@tedunangst.com
Fri, 19 Apr 2019 11:32:01 -0400
1 files changed,
1 insertions(+),
20 deletions(-)
jump to
M
fun.go
→
fun.go
@@ -18,7 +18,6 @@
import ( "crypto/rand" "crypto/rsa" - "database/sql" "fmt" "html" "html/template"@@ -77,31 +76,13 @@ }
func xfiltrate() string { letters := "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz1234567891234567891234" - db := opendatabase() for { - var x int64 - var b [16]byte + var b [18]byte rand.Read(b[:]) for i, c := range b { b[i] = letters[c&63] } s := string(b[:]) - r := db.QueryRow("select honkid from honks where xid = ?", s) - err := r.Scan(&x) - if err == nil { - continue - } - if err != sql.ErrNoRows { - log.Panicf("err picking xid: %s", err) - } - r = db.QueryRow("select fileid from files where xid = ?", s) - err = r.Scan(&x) - if err == nil { - continue - } - if err != sql.ErrNoRows { - log.Panicf("err picking xid: %s", err) - } return s } }