hash

Decode email address from Gravatar hash?

I suppose, Gravatar generates the image from email address. If so, the reverse should be possible. How difficult would be to get the email associated with the image? Isnt it a potential spam threat? What are your thoughts? (other than calling me paranoid ;) i did that already) ...

What's the safest way to iterate through the keys of a Perl hash?

If I have a Perl hash with a bunch of (key, value) pairs, what is the preferred method of iterating through all the keys? I have heard that using each may in some way have unintended side effects. So, is that true, and is one of the two following methods best, or is there a better way? # Method 1 while (my ($key, $value) = each(%hash)...

What is the best way to create a sparse array in C++

Hi everyone, I am working on a project that requires the manipulation of enourmous matrices, particularly pyramidal summation for a copula calculation. In short, I need to keep track of a relatively small number of values (usually a value of 1, and in rare cases more than 1) in a sea of zeros in the matrix (multidimensional array). A s...

How would a sdbm hash function be implemented in C#?

How will a sdbm hash function (such as http://www.cse.yorku.ca/~oz/hash.html) be implemented in C# ? ...

How do I generate a hashcode from a byte array in c#

Say I have an object that stores a byte array and I want to be able to efficiently generate a hashcode for it. I've used the cryptographic hash functions for this in the past because they are easy to implement, but they are doing a lot more work than they should to be cryptographically oneway and I don't care about that (I'm just using ...

How to find keys of a hash?

I know in javascript Objects double as hashes but i have been unable to find a built in function to get the keys var h = {a:'b',c:'d'}; I want something like var k = h.keys() ; // k = ['a','c']; It is simple to write a function myself to iterate over the items and add the keys to an array that I return, but is there a standard cl...

why are downloads sometimes tagged md5, sha1 and other hash indicators?

I've seen this all over the place: Download here! SHA1 = 8e1ed2ce9e7e473d38a9dc7824a384a9ac34d7d0 what does it mean? how does a hash come into play as far as downloads and... what use can I make of it? Is this a legacy item where you used to have to verify some checksum after you downloaded the whole file? Just curious, Cheers...

How would you implement a hashtable in language x?

The point of this question is to collect a list of examples of hashtable implementations using arrays in different languages. It would also be nice if someone could throw in a pretty detailed overview of how they work, and what is happening with each example. Edit: Why not just use the built in hash functions in your specific languag...

How Do I Create a Hash Table in Java?

What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do this? And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the object for each pair? ...

How do I create a SHA1 hash in ruby?

SHA Hash functions ...

What is a good Hash Function?

What is a good Hash function? I saw a lot of hash function and applications in my data structures courses in college, but I mostly got that it's pretty hard to make a good hash function. As a thumble rule to avoid collisions my professor said that: function Hash(key) return key mod PrimeNumber end (mod is the % operator in C and sim...

Saving Perl Windows Environment Keys UPCASES them

Hi, I have a framework written in Perl that sets a bunch of environment variables to support interprocess (typically it is sub process) communication. We keep a sets of key/value pairs in XML-ish files. We tried to make the key names camel-case somethingLikeThis. This all works well. Recently we have had occasion to pass control (c...

Given that I have a hash of id(key) and countries(values) sorted alphabetically, what is the best way to bubble up an entry to the top of the stack?

This is a php example, but an algorithm for any language would do. What I specifically want to do is bubble up the United States and Canada to the top of the list. Here is an example of the array shortened for brevity. array( 0 => '-- SELECT --', 1 => 'Afghanistan', 2 => 'Albania', 3 => 'Algeria', 4 => 'American Samoa', 5 =...

Search by hash?

I had the idea of a search engine that would index web items like other search engines do now but would only store the file's title, url and a hash of the contents. This way it would be easy to find items on the web if you already had them and didn't know where they came from or wanted to know all the places that something appeared. Mo...

How to get hashes out of arrays in Perl?

I want to write a little "DBQuery" function in perl so I can have one-liners which send an SQL statement and receive back and an array of hashes, i.e. a recordset. However, I'm running into an issue with Perl syntax (and probably some odd pointer/reference issue) which is preventing me from packing out the information from the hash that ...

Can I depend on the values of GetHashCode() to be consistent?

Hi, Is the return value of GetHashCode() guaranteed to be consistent assuming the same string value is being used? (C#/ASP.NET) I uploaded my code to a server today and to my surprise I had to reindex some data because my server (win2008 64-bit) was returning different values compared to my desktop computer. ...

How do I hash a string with Delphi?

What hash algorithms does Delphi support? ...

Detect changes in random ordered input (hash function?)

I'm reading lines of text that can come in any order. The problem is that the output can actually be indentical to the previous output. How can I detect this, without sorting the output first? Is there some kind of hash function that can take identical input, but in any order, and still produce the same result? ...

Unique ID c++

What is the best way to generate a Unique ID from two (or more) short ints in C++? I am trying to uniquely identify vertices in a graph. The vertices contain two to four short ints as data, and ideally the ID would be some kind of a hash of them. Prefer portability and uniqueness over speed or ease. There are a lot of great answers...

Is there any way to use a "constant" as hash key in Perl?

Is there any way to use a constant as a hash key? For example: use constant X => 1; my %x = (X => 'X'); The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key. ...