Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fingerprint/hash function for strings #403

Open
charlesstaats opened this issue Nov 29, 2023 · 0 comments
Open

Fingerprint/hash function for strings #403

charlesstaats opened this issue Nov 29, 2023 · 0 comments

Comments

@charlesstaats
Copy link
Contributor

It is generally accepted that fingerprint and hashing functions should be written in fully compiled languages, as they are highly inefficient otherwise.

I request a new Asymptote builtin function to take a fingerprint/hash of a string, for two purposes:

  • To construct filenames dynamically based on the contents of the file (so that two files with different contents will be all but guaranteed different filenames). This is useful when creating files dynamically to be subsequently imported.
  • To create hashtable classes with strings as keys.

An important detail for the first usage is that it should be possible to use this builtin function to create long enough hashes to all but guarantee uniqueness (since having a filename collision would likely cause an error rather than just a slightly longer running time). I recommend https://github.com/google/highwayhash as a library that can provide fast, high-quality hashes in C/C++ up to 256 bits.

For the exact signature of the builtin, I recommend returning an array of ints (each having 32 bits of information, since Asymptote has no uint64 type). Potentially, the length of the returned array could depend on a user-provided parameter, so that extra effort is not used to compute unneeded bits.

@charlesstaats charlesstaats linked a pull request Dec 21, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant