I am looking for hash function
, that I can use in Postgresql
to be more specific in Amazon Aurora Db
. The Hash
value generated should be of 8 bytes long that can be stored in string
field of length 8.
Do we have any such hash function
that matches the above mentioned criteria. Any leads on this would be really helpful. Thank you.
2
Answers
You can use the built-in hash function
MD5
, which produces a32-character
text string.Then truncate to
8
bytes by using thesubstring(string, start_position, length )
You cannot store 8 bytes as 8 characters. But a
bytea
would work; for example