hash

Generate a client-specific verification number for a web service

I have a web service that is outward-facing, however I need to generate a verification system to ensure that a request came from a valid client. Let's say the original web service is defined as follows: [OperationContract] public void Service.RequestMethod (string clientId, int reqNumber, string reqText) { // do stuff with the ...

Time-sensitive message verification hash - getting a loose time value

I'm looking at generating pseudo-random one-time-passwords that are time sensitive. To send a message, the user enters their password which gets hashed together with the message. The resultant hash is sent with the message to the server for verification. The server performs the same hash and compares its value to the one provided. ve...

How would you go about designing a function for a perfect hash?

The domain of interest is string matching. Assume I have a structure like this. typedef struct { char *name, int (*function)(); } StringArray StringArray s[] = { {"George", func1}, {"Paul", func2}, {"Ringo", func3}, {"John", func4} } There are a fixed number of strings in the array. They are hard cod...

Hash function for a pair of long long?

I need to map a pair of long long to a double, but I'm not sure what hash function to use. Each pair may consist of any two numbers, although in practice they will usually be numbers between 0 and about 100 (but again, that's not guaranteed). Here is the tr1::unordered_map documentation. I started like this: typedef long long Int; type...

What format is the output of HashPasswordForStoringInConfigFile () and how to store it the best?

I'm using this function to generate a hash for a password and then store it in the database (SQL Server). The code looks like this: byte[] saltBytes = new byte[16]; new RNGCryptoServiceProvider ().GetBytes (saltBytes); string salt = Convert.ToBase64String (saltBytes); string saltedPasswordHash = FormsAuthentication.HashPasswordForStori...

Converting an array of keys and an array of values into a hash in Ruby

I have two arrays like this: keys = ['a', 'b', 'c'] values = [1, 2, 3] Is there a simple way in Ruby to convert those arrays into the following hash? { 'a' => 1, 'b' => 2, 'c' => 3 } Here is my way of doing it, but I feel like there should be a built-in method to easily do this. def arrays2hash(keys, values) hash = {} 0.upto(k...

A minimal hash function for C?

I can't use boost:hash because I have to stick with C and can't use C++. But, I need to hash a large number (10K to 100k) of tokens strings (5 to 40 bytes length) so that search within those are fastest. MD5, SHA1 or any long hash function seems too heavy for a simple task, I am not doing cryptography. Plus there is the storage and com...

What does it mean to 'hash cons'?

When to use it and why? My question comes from the sentence: "hash cons with some classes and compare their instances with reference equality" ...

Confused about hashes

say I have a blob of text 5000 characters. I run it through a hashing program and generates a 40 char long hash. now i run another blob of text, 10000 characters. it still generates a hash 40 chars long. that's true for text of any length. my question is if the hashes are all unique, wouldn't i be able to compress anything into a 40 cha...

Ruby hash initialization: is this niftyness possible?

This code works, of course: @x = { :all => { :x => 1, :y => 2 } } But this doesn't: @x = { :abc, :all => { :x => 1, :y => 2 } } Is there any way to do what I want here? i.e. I want two keys in a hash to each refer to the same (copy of a) value. But I only want to specify the value once. ...

Remove from a HashSet failing after iterating over it

I'm writing an agglomerative clustering algorithm in java and having trouble with a remove operation. It seems to always fail when the number of clusters reaches half the initial number. In the sample code below, clusters is a Collection<Collection<Integer>>. while(clusters.size() > K){ // determine smallest distance b...

OK to use only 64-bits of sha1 hash as an id?

1) For the purpose of really low hash collision, can I get away with just using half of the 128 bits of a sha1 rather than dealing with the sha1 itself? I understand this is not suitable for cryptographic hashes, but I just need the hashes for hash table keys. 2) Computation time isn't a priority, and besides which I'm hashing very smal...

Best Hash function for detecting data changes?

We have a pricing dataset that changes the contained values or the number of records. The number of added or removed records is small compared to the changes in values. The dataset usually has between 50 and 500 items with 8 properties. We currently use AJAX to return a JSON structure that represents the dataset and update a webpage usi...

what's the best way to convert a ruby hash to an array

Hi All, I have a ruby hash that looks like this { "stuff_attributes" => { "1" => {"foo" => "bar", "baz" => "quux"}, "2" => {"foo" => "bar", "baz" => "quux"} } } and I want to turn it into a hash that looks like this { "stuff_attributes" => [ { "foo" => "bar", "baz" => "quux"}, { "foo" => "bar", "baz" => "quux"...

Sort by value hash of hash of hashes Perl

I have a hash structure similar to the following: KeyA => { Key1 => { Key4 => 4 Key5 => 9 Key6 => 10 } Key2 => { Key7 => 5 Key8 => 9 } } KeyB => { Key3 => { ...

Do hashes in URLs affect SEO?

If I've got 2 (or more) URLs (where the only difference is the hash value) to my homepage will Google divide my page rank between those pages or is it 'safe' to have lots of different hashes in the URL and still keep one page rank? Example: http://example.com/ http://example.com/#hash ...

View assembly hash

Hi I have signed my assembly with strong key. I am able to locate public key in assembly manifest using ildasm. I am not able however to locate assembly hash which should be placed in assembly along with the public key. Where can I find computed hash? Kind regards PK ...

Is MD5 less secure than SHA et. al. in a practical sense?

I've seen a few questions and answers on SO suggesting that MD5 is less secure than something like SHA. My question is, Is this worth worrying about in my situation? Here's an example of how I'm using it: On the client side, I'm providing a "secure" checksum for a message by appending the current time and a password and then hashing ...

tr1::hash for boost::thread::id?

Dear all: I started to use the unordered_set class from the tr1 namespace to speed-up access against the plain (tree-based) STL map. However, I wanted to store references to threads ID in boost (boost::thread::id), and realized that the API of those identifiers is so opaque that you cannot clearly obtain a hash of it. Surprisingly, boo...

hash as def argument

Is the following possible in any way? I keep running into a odd number list for Hash def thores_hammer(bling) hammer_bling = { bling } end thores_hammer :rubys => 5, :emeralds => 5, :souls => 333 Thanks ahead of time. ...