hash

Why does Perl treat a hash element as list context at declaration?

Given this code: #!/usr/bin/perl -w use strict; use warnings; sub foo { return wantarray ? () : "value1"; } my $hash = { key1 => foo(), key2 => 'value2' }; use Data::Dumper; print Dumper($hash); I get the following output: $VAR1 = { 'key1' => 'key2', 'value2' => undef }; When I would expect: $VAR1 = { 'key1' ...

Why are XOR often used in java hashCode() but another bitwise operators are used rarely?

I often see code like int hashCode(){ return a^b; } Why XOR? ...

python, hash function selection

Hello Using Python and Django, I will let my users to give pdf based gifts to their friends, which the said friend will be able to claim pdf by entering to my site from the emailed link. Here is the plan User gives a gives to his friend, enters friends email In the background, a gift model is saved which will contain a uniquely gener...

Does PHP hash() support WHIRLPOOL by default?

I was just wondering if PHP's hash function supported WHIRLPOOL by default. I believe it is but i wanted to ask to be sure. ...

SSAS error when deploying cube in BIDs

I am getting the following error when deploying. This is in a cube which was working fine, all that has changed is a key column in one of the dimensions. Internal error: Failed to generate a hash string I have no idea what is causing this but even if I change the dimension back to how it was and try to deploy I get the same error. If...

What is the best 32bit hash function for short strings (tag names)?

What is the best 32bit hash function for relatively short strings? Strings are tag names that consist of English letters, numbers, spaces and some additional characters (#, $, ., ...). For example: Unit testing, C# 2.0. I am looking for 'best' as in 'minimal collisions', performance is not important for my goals. ...

What does {$histogram{$value}++} mean in Perl?

The whole subroutine for the code in the title is: sub histogram { # Counts of elements in an array my %histogram = () ; foreach my $value (@_) {$histogram{$value}++} return (%histogram) ; } I'm trying to translate a Perl script to PHP and I'm having difficulties with it (I really don't know anything of Perl but I'm trying). So...

Tamperproof table

I'm designing a table that will be used to store information on which customers will be charged. The problem is the database could be on the customers servers. I was thinking of adding a second table containing a hash of the first, so that the software using the database can update the database and the hash, but the customers can't edit ...

Is it advisable to store a hashed password in a cookie?

I want user's to be able to select a "remember me" box on my website so they need not log in each time they come. So, I need to store a unique ID in a cookie to identify them. Is it safe to hash their password with sha512 and a long salt in PHP and store that value in the cookie? If the cookie was stolen, would their password be at risk?...

How to iterate through Hash (of Hashes) in Perl?

Hello, I have Hash where values of keys are other Hashes. Example: {'key' => {'key2' => {'key3' => 'value'}}} How can I iterate through this structure? ...

What exactly is a hash in regards to JSON?

I am learning JSON, but I found out that you can put what are called "hashes" into JSON as well? Where can I find out what a hash is? Or could you explain to me what a hash is? Also, what's a hashmap? I have experience in C++ and C#, and I am learning JS, Jquery, and JSON. ...

Hashing SMTP and NNTP messages?

I want to store and index all of my historical e-mail and news as individual message files, using some computed hash code based on the message body+headers. Then I'll index on other things as well -- for searching. For the primary index key, my thought is to use SHA-1 for the hash algorithm and assume that there will never be any colli...

Does a hash salt have any other use than to prevent rainbow table attacks?

I have heard that the only purpose of a salt is to prevent rainbow table attacks, but surely it must have more value than this? Would it not prevent a dictionary-based attack too? And what about brute-forcing, would a salt be of any use there? And could you explain why, please? Second, suppose I had an algorithm that took the microtime,...

Why are hash table expansions usually done by doubling the size?

I've done a little research on hash tables, and I keep running across the rule of thumb that when there are a certain number of entries (either max or via a load factor like 75%) the hash table should be expanded. Almost always, the recommendation is to double (or double plus 1, i.e., 2n+1) the size of the hash table. However, I haven'...

salt and hash generation question

Hi, I would just like your feedback on something. Basically I have a value called $uniqueID which is = ID + First Letter of First Name + First Letter of Last Name + The String "CAN" I have then turned $uniqueID into a salt value as followed $salt = sha1($uniqueID); I have then turned the user's password into a hash value using md5(...

How to check whether my custom hashing is good in hash_map?

I've written a custom hashing for my custom key in stdext::hash_map and would like to check whether the hasher is good. I'm using STL supplied with VS 2008. A typical check, as I know, is to check the uniformity of distribution among buckets. How should I organize such a check correctly? A solution that comes to my mind is to modify ST...

In Perl, how can I import a hash from a library?

I have a file revs.pm: my %vers = ( foo => "bar" ); And another file like importer.pl: use revs; How can I access %vers from importer.pl ? ...

Perl: Access a hashref sorted by value

I'm writing a script that'll read through my ftpd logs and generate a hash as follows: $stats = \{ 'user1' => { 'files' => 281, 'size' => '3724251021' }, 'user2' => { 'files' => 555, 'size' => '738585...

Inclusion of hash marks in a LaTeX \indexentry aliased with a \newcommand

This is a strange one. I've had to do some interesting workarounds to get it to function even a little bit, but we have another stumbling block. I've been struggling to create a separate document which employs a large .ind file (index created using makeindex from catenated, small individual .idx files), the idea being that I will event...

What is the behavior of ruby Hash#merge when used with a block

It does not seem to be documented very much: hsh.merge(other_hash){|key, oldval, newval| block} → a_hash http://ruby-doc.org/core/classes/Hash.html#M002880 ...