image thumbnail

ComputeNonCryptHash

version 2.1.0 (85 KB) by Rik
Compute a non-cryptographic hash

14 Downloads

Updated 19 May 2021

From GitHub

View license on GitHub

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.

Cite As

Rik (2021). ComputeNonCryptHash (https://github.com/thrynae/ComputeNonCryptHash/releases/tag/v2.1.0), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with R13SP1 and later releases
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.