This function is intended to be fast, but without requiring a Java or mex implementation to do the actual hashing. It was *not* checked for any security flaws and is therefore probably vulnerable to most attacks.
Non-cryptographic hashes should only be used as a checksum. Don't use this to do things like storing passwords.
This function will transform most common data types to a uint16 vector to apply the hash in an array operation. Changing the data type should change the hash. The allowed data types are uint*, int*, char, cell, struct, double, single, and string (which is cast to cell array of chars). The contents of the nested data types (i.e. cell and struct) must also be one of the mentioned data types.
Version 1.x of this algorithm attempts to cast string to char, instead of a cell array of chars. Version 1.x also has many hash collisions for scalar doubles. Version 2 will transcode the UTF-8 chars on Octave to UTF-16 (the Matlab standard), which ensures that the same Unicode code points as input will return the same hash.
Rik (2021). ComputeNonCryptHash (https://github.com/thrynae/ComputeNonCryptHash/releases/tag/v2.1.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!