Allow compressing hashes into a single UInt
or Vector{UInt}
#7
Labels
enhancement
New feature or request
UInt
or Vector{UInt}
#7
Problem
The hashes returned by most hash functions tend to use a lot of memory. For instance, a length-0
Vector{Int64}
(e.g. as returned byLpHash
) is 40 bytes:Moreover, using these hashes as a key into a database or hash table is difficult since in general they may not understand the datatype being used for the key.
Proposed solution
The solution I'm proposing is to add a function
compress_hash
that accepts aVector{<:Integer}
orBitArray{1}
and converts it into aUInt32
,UInt64
, orVector{UInt8}
.hash
function and simple letcompress_hash(x) = hash(x)
, which returnsUInt64
.x
as anArray{UInt8}
and usesha256(x)
, which returnsVector{UInt8}
.Notes
compress_hash
needs to be cryptographically secure. I suspect that it should be in order to be on the safe side for various potential applications of this package. In that case, we will need to define a type such assha256
, though it's unlikely that we'll be hashing anything large enough to justify going to great lengths in order to do this.The text was updated successfully, but these errors were encountered: