all repos — honk @ 2f6e8e50ab7728478a91f135cd0ae41866fd8d0c

my fork of honk

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
commit

2f6e8e50ab7728478a91f135cd0ae41866fd8d0c

parent

12e1deac71cc9338bc2adb90740bd86685f09391

1 files changed, 1 insertions(+), 20 deletions(-)

jump to
M fun.gofun.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 } }