String2Hash

Convert a String Array (Text) to a hash code
2,1K téléchargements
Mise à jour 18 juin 2010

Afficher la licence

This function generates a hash value from a text string

hash=string2hash(str,type);

inputs,
str : The text string, or array with text strings.
outputs,
hash : The hash value, integer value between 0 and 2^32-1
type : Type of has 'djb2' (default) or 'sdbm'

From c-code on : http://www.cse.yorku.ca/~oz/hash.html

djb2
this algorithm was first reported by dan bernstein many years ago
in comp.lang.c

sdbm
this algorithm was created for sdbm (a public-domain reimplementation of
ndbm) database library. it was found to do well in scrambling bits,
causing better distribution of the keys and fewer splits. it also happens
to be a good general hashing function with good distribution.

example,

hash=string2hash('hello world');
disp(hash);

Citation pour cette source

Dirk-Jan Kroon (2025). String2Hash (https://www.mathworks.com/matlabcentral/fileexchange/27940-string2hash), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2010a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Characters and Strings dans Help Center et MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0.0