use two more bytes for xid, but don't bother looking for dupes.

102 bits ought to be enough for anyone
This commit is contained in:
Ted Unangst 2019-04-19 11:32:01 -04:00
parent b5249fd53d
commit f5cbf4cadc
1 changed files with 1 additions and 20 deletions

21
fun.go
View File

@ -18,7 +18,6 @@ package main
import (
"crypto/rand"
"crypto/rsa"
"database/sql"
"fmt"
"html"
"html/template"
@ -77,31 +76,13 @@ func reverbolate(honks []*Honk) {
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
}
}