Code covered by the BSD License  

Highlights from
String2Hash

Be the first to rate this file! 8 Downloads (last 30 days) File Size: 1.63 KB File ID: #27940

String2Hash

by Dirk-Jan Kroon

 

18 Jun 2010

Convert a String Array (Text) to a hash code

| Watch this File

File Information
Description

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);

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
hash Dirk-Jan Kroon 18 Jun 2010 10:22:01
string Dirk-Jan Kroon 18 Jun 2010 10:22:01
string2hash Dirk-Jan Kroon 18 Jun 2010 10:22:01
djb2 Dirk-Jan Kroon 18 Jun 2010 10:22:01
encoding Dirk-Jan Kroon 18 Jun 2010 10:22:01
text Dirk-Jan Kroon 18 Jun 2010 10:22:01
hashvalue Dirk-Jan Kroon 18 Jun 2010 10:22:01
sdbm Dirk-Jan Kroon 18 Jun 2010 10:22:01
encoding ivi Dehqan 12 Aug 2010 01:55:56

Contact us at files@mathworks.com