hash

What's a real world example of something you would represent with a hash?

I'm just trying to get a grip on when you would need to use a hash and when it might be better to use an array. What kind of real-world object would a hash represent, say, in the case of strings? ...

firefox cache hash key generation algorithm bug

There is a bug in Firefox (even in the new betas and in minefield releases) which prevents the caching of certain files because of the algorithm for creating a key in their cache hash. Here is a link to the source code of the function. I want to ensure that all of my site's files can be cached. However, I do not understand why their...

Getting hash of a list of strings

I would like to write a function GetHashCodeOfList() which returns a hashcode of a list of strings regardless of order. Given 2 lists with the same strings should return the same hashcode. ArrayList list1 = new ArrayList() list1.Add("String1"); list1.Add("String2"); list1.Add("String3"); ArrayList list2 = new ArrayList() l...

Salting Your Password: Best Practices?

I've always been curious... Which is better when salting a password for hashing: prefix, or postfix? Why? Or does it matter, so long as you salt? To explain: We all (hopefully) know by now that we should salt a password before we hash it for storage in the database [Edit: So you can avoid things like what happened to Jeff Atwood recentl...

What is a good hashing algorithm for seeding a prng with a string?

I am looking for a hashing algorithm that produces a 31/32 bit signed/unsigned integer as a digest for a utf8 string with the purpose of using the output for seeding a prng, such as a Park-Miller-Carta LCG or a Mersenne-Twister. I have looked into FNV1 and FNV1a, but they provide very close values for similar strings differing in their ...

CPAN modules for computing integer hash keys based on short strings

I'm looking for a CPAN module that will take a short string: my $hash_value = hash_this('short string not too long'); And hash it into an integer key: say $hash_value; 12345671234 # an integer key ...

How to calculate the odds of a collision in hash algorithms?

Say I have a hash algorithm, and it's nice and smooth (The odds of any one hash value coming up are the same as any other value). Now say that I know that the odds of picking 2 hashes and there being a collision are (For arguments sake) 50000:1. Now say I pick 100 hashes. How do I calculate the odds of a collision within that set of 10...

hash function providing unique uint from an integer coordinate pair

The problem in general: I have a big 2d point space, sparsely populated with dots. Think of it as a big white canvas sprinkled with black dots. I have to iterate over and search through these dots a lot. The Canvas (point space) can be huge, bordering on the limits of int and its size is unknown before setting points in there. That brou...

Hashing function used in Java Language

Hi all I know that Java has beautiful inbuilt support for the HashMaps or HashTables. Does anybody have knowledge that what kind of hashing functions or techniques are employed by Java language? Is it possible to tweak those functions to be able to make them more specific to one's application in order to improve performance and redu...

Is there a CPAN module that digests a short string into a short number?

I need to create unique numerical ids for some short strings. some.domain.com -> 32423421 another.domain.com -> 23332423 yet.another.com -> 12131232 Is there a Perl CPAN module that will do something like this? I've tried using Digest::MD5 but the resulting numbers are too long: some.domain.com -> 29680057245717615035661393...

Find the mode of an array of floating point numbers using hashing

I recently read that a method involving hashing could be a good way to find the mode of an array of floating point numbers. I don't know much about hashing or its applications and the text didn't explain further. Does anyone know what this method would involve? ...

how do I create a mySQL user with hash('sha256', $salt . $password)?

I must be missing something. I want to set up a database user account for select-only transactions but mysql is not letting me choose the hash method for a password on creating a user account. this fails: GRANT SELECT ON myDB.* TO 'selectuser'@'localhost' IDENTIFIED BY hash('sha256', 'salted-myfakelongrandompasswordstring'); ERROR ...

Does the hash algorithm used for password hashing affect rainbow table generation?

re question non-random-salt-for-password-hashes Mr Potato Head states that the use of md5 instead of SHA-512 makes generating rainbow tables easier? I'd have thought that once your rainbow table is generated that the algorithm used is irrelevant? It would make no difference to how you use the rainbow table to check for known hashs? An...

How to set the crypto key for Python's MD5 module?

What is the Python equivalent of following Perl code? hmac_md5_hex($login . "^" . $seq . "^" . $time . "^" . $amo . "^", $CryptoKey); The Python hashlib.md5 doesn't seem to take an "cryptographic key" argument. It only accepts 1 argument. ...

Computing hashes for strings in SQL Server database - worth the effort?

Say I have a million-row table [mytable] in my SQL Server 2005 database, which has columns: ID SomeField AnotherField Url A very common query in this system is: select * from [mytable] where url = 'http://www.somesite.com/some/really/long/url' Which will give me better performance: a) Add an index to the Url column. or b) Add an...

Maintaining message integrity

I have a message that I am passing to myself which will be subject to man-in-the-middle attacks. Because of that, I am concerned about the integrity of the message being maintained between the time I send it, and the time that I receive it back. It should be assumed that once I send the message to myself, no information about the messa...

Fast implementation of Rolling hash

I need a Rolling hash to search for patterns in a file. (I am trying to use the rabin-Karp string search algorithm). I understand how a good hash works and how a good rolling hash should work but I am unable to figure out how to efficiently implement the 'divide' (or inverse multiplication) when rolling the hash. I also read rsync uses ...

Ruby Hash Filter

Hello I am trying to figure out how I can filter out key and value pairs from one filter into another For example I want to take this hash x = { "one" => "one", "two" => "two", "three" => "three"} y = x.some_function y = { "one" => "one", "two" => "two"} Thanks for your help ...

Computing file HASH returns different values.

Does anybody know, why the following code returns different results on some machines? Private Shared Function ComputeHashValue(ByVal Data As String) As String Dim HashAlgorithm As SHA512 = SHA512.Create Dim HashValue() As Byte = HashAlgorithm.ComputeHash(Encoding.ASCII.GetBytes(Data)) ' Looping over the array and ANDing each...

How can I create an anonymous hash from an existing hash in Perl?

Hello, How can I create an anonymous hash from an existing hash? For arrays, I use: @x = (1, 2, 3); my $y = [@x]; but I can't find how to do the same for a hash: my %x = (); my $y = ???; Thanks ...