草庐IT

integer-hashing

全部标签

hash - Go:为什么我的哈希表实现这么慢?

所以我正在尝试制作一个超轻量级、故意占用大量内存但非常快速的哈希表,用于非常快速的查找,我不关心内存使用情况,也不关心它是否会犯罕见的错误。基本上它只是创建一个巨大的数组(是数组,不是slice),使用修改后的FNVa散列(修改为仅给出数组边界内的散列)对字符串进行散列,然后使用散列保存或查找值作为数组索引。理论上,这应该是存储和检索键=>值对的最快方法。这是我的基准:packagemainimport("fmt""time")constdicsize250=2097152000//tested115collisionstypeDictionary250_uint16struct{di

hash - 如何在Go中实现HashCash的算法(类型转换问题)?

我一直在尝试用Go实现HashCash算法!对于那些不知道的人-HashCashisamethodtostopspam.Basically,aheaderisconstructedofsomeenvironmentvariablesknownbothtotheclientandserver(email,timestampetc.).Arandomnonceisappendedtotheendoftheheader.Theclienttriestobruteforceapartialhashcollision(e.g.wherethefirstxbitsare0)bychangingth

hash - 如何在Go中实现HashCash的算法(类型转换问题)?

我一直在尝试用Go实现HashCash算法!对于那些不知道的人-HashCashisamethodtostopspam.Basically,aheaderisconstructedofsomeenvironmentvariablesknownbothtotheclientandserver(email,timestampetc.).Arandomnonceisappendedtotheendoftheheader.Theclienttriestobruteforceapartialhashcollision(e.g.wherethefirstxbitsare0)bychangingth

postgresql - pq : invalid input syntax for integer: "$1"

在我尝试从Go应用程序INSERT到postgresql数据库简单语句后,发生了这个错误。我已经为int(value)做了类型断言,但没有成功。 最佳答案 我已经通过从我的INSERT语句中删除单引号解决了这个问题。插入kids(age,user_id)值($1,$2);代替insertintokids(age,user_id)values('$1','$2'); 关于postgresql-pq:invalidinputsyntaxforinteger:"$1",我们在StackOver

postgresql - pq : invalid input syntax for integer: "$1"

在我尝试从Go应用程序INSERT到postgresql数据库简单语句后,发生了这个错误。我已经为int(value)做了类型断言,但没有成功。 最佳答案 我已经通过从我的INSERT语句中删除单引号解决了这个问题。插入kids(age,user_id)值($1,$2);代替insertintokids(age,user_id)values('$1','$2'); 关于postgresql-pq:invalidinputsyntaxforinteger:"$1",我们在StackOver

file - Go中如何一步返回hash和bytes?

我试图了解如何读取文件内容、计算其哈希值并一次性返回其字节。到目前为止,我分两步进行,例如//calculatefilechecksumhasher:=sha256.New()f,err:=os.Open(fname)iferr!=nil{msg:=fmt.Sprintf("Unabletoopenfile%s,%v",fname,err)panic(msg)}deferf.Close()b,err:=io.Copy(hasher,f)iferr!=nil{panic(err)}cksum:=hex.EncodeToString(hasher.Sum(nil))//readagain(

file - Go中如何一步返回hash和bytes?

我试图了解如何读取文件内容、计算其哈希值并一次性返回其字节。到目前为止,我分两步进行,例如//calculatefilechecksumhasher:=sha256.New()f,err:=os.Open(fname)iferr!=nil{msg:=fmt.Sprintf("Unabletoopenfile%s,%v",fname,err)panic(msg)}deferf.Close()b,err:=io.Copy(hasher,f)iferr!=nil{panic(err)}cksum:=hex.EncodeToString(hasher.Sum(nil))//readagain(

node:internal/crypto/hash:71 this[kHandle] = new _Hash(algorithm, xofLen); 解决方法

执行yarndev或者npmrundev时出现错误:node:internal/crypto/hash:67this[kHandle]=new_Hash(algorithm,xofLen);^Error:error:0308010C:digitalenveloperoutines::unsupportedatnewHash(node:internal/crypto/hash:67:19)atObject.createHash(node:crypto:130:10)说明node版本太高,卸载node安装低版本node推荐使用16.19.0的版本地址:https://nodejs.org/down

hash - Go:这个散列函数的范围如何从 0-32 位?

我正在尝试编写我自己的使用30位散列的散列函数。这是FNVa32位哈希的一些代码。funcfnva32(datastring)uint32{varhashuint32=2166136261for_,c:=rangedata{hash^=uint32(c)hash*=16777619}returnhash}现在这是我将小写字母a-z转换为30位散列的代码:funcid(sstring)uint{variduintvarpoweruint=1for_,c:=ranges{id+=(uint(c)-96)*powerpower*=26}returnid%1073741824}这特别将我的哈希

hash - Go:这个散列函数的范围如何从 0-32 位?

我正在尝试编写我自己的使用30位散列的散列函数。这是FNVa32位哈希的一些代码。funcfnva32(datastring)uint32{varhashuint32=2166136261for_,c:=rangedata{hash^=uint32(c)hash*=16777619}returnhash}现在这是我将小写字母a-z转换为30位散列的代码:funcid(sstring)uint{variduintvarpoweruint=1for_,c:=ranges{id+=(uint(c)-96)*powerpower*=26}returnid%1073741824}这特别将我的哈希