hash

HTML Form method = HASH?

If I set my Form method to GET it will send the action page something like this: action_page.php?key=value&foo=bar But is there a way to make it send like this: action_page.php#key=value&foo=bar Because the page receiving the values relies on hash variables. Thanks! ...

How can I elegantly create a hash from an array reference in Perl?

Hi, I am looking for a more elegant way to create a hash that contains the list I have read in from my configuration file. Here is my code: read_config($config_file => my %config); my $extension_list_reference = $config{extensions}{ext}; my @ext; # Store each item of the list into an array for my $i ( 0 .. (@$extension_list_refere...

bracket syntax for Ruby Hashes

Do these two statements pass the same type of argument (a Hash) to the new method? @seat = Seat.new(:flight_id => @flight.id) @seat = Seat.new({:flight_id => @flight.id}) Do the Hash brackets {} change anything in the second example? ...

Are the first 32 bits of a 160-bit SHA1 hash an acceptable substitute for a CRC32 hash?

I'm working on a .NET 3.5 project and I need a 32-bit hash value. There doesn't seem to be any methods in the .NET Cryptography classes that return a 32-bit hash (MD5 is 128 bits, SHA1 is 160 bits, etc.). I implemented a CRC32 class, but I find that the SHA1 and MD5 hashing functions that already exist are much faster. Would there be ...

Should Perl hashes always contain values?

I had an earlier question that received the following response from the noted Perl expert, Perl author and Perl trainer brian d foy: [If] you're looking for a fixed sequence of characters at the end of each filename. You want to know if that fixed sequence is in a list of sequences that interest you. Store all the extensions in a hash ...

Reason for Sorting a Hash Table

I was asked by an employer to sort a hash table. I always thought that the usage of a hash table was in a way non-sort friendly. Am I wrong in thinking this, and if not can you point me to a good VB.Net(Yes Kill me now, but it's an old system) method of sorting a hash table. Thanks. ...

Create your own MD5 collisions

I'm doing a presentation on MD5 collisions and I'd like to give people any idea how likely a collision is. It would be good to have two blocks of text which hash to the same thing, and explain how many combinations of [a-zA-Z ] were needed before I hit a collision. The obvious answer is hash every possible combination until hit two has...

Search for hash in an array by value

Hello, I have a function which extracts Excel data into an array of hashes like so: sub set_exceldata { my $excel_file_or = '.\Excel\ORDERS.csv'; if (-e $excel_file_or) { open (EXCEL_OR, $excel_file_or) || die("\n can't open $excel_file_or: $!\n"); while () { chomp; ...

Hash function to matrix

I have two matrices and I need to compare them, but I don't want to compare position by position, I think that is not the best way. I thought of hash functions, does anyone know how to calculate the hash of a matrix? ...

How should 'raw binary data' hashes be stored in MySQL?

I'm wanting to store hashed passwords in MySQL, I'm using PHP: <?php $salt = '!£$%^&*()#'; $username = 'abc'; $password = '123'; $hash = hash('sha1', $username . $salt . $password, true); ?> The true parameter in hash() will return the value as raw binary data. But I don't understand what this means exactly. How should...

Can PHP read the hash portion of the URL?

Assuming a URL of: www.mysite.com?val=1#part2 PHP can read the request variables "val1" using the GET array. Is the hash value "part2" also readable? or is this only upto the browser and JavaScript. ...

Could a page display diferrent content if the URL hash changes?

How could a page display different content based on the URL hash? I'm not talking about the browser scrolling down to display the anchored section, but something like JavaScript reacting to that hash and loading different content via AJAX. Is this common or even probable? ...

How can I use hashes as arguments to subroutines in Perl?

Hello, I have a function that is doing some calculations and then passes some properties into another subroutine like so: sub get_result { my $id = 1; my %diet = ( result => 28, verdict => 'EAT MORE FRUIT DUDE...' ); my %iq = ( result => 193, verdict => 'Profess...

Can a search engine link to a certain section of an HTML file?

If I have a page divided in sections/fragments, that are linked to within the page with anchors, like this: <div class="menu"> <a href="#sec1">Section 1</a> <a href="#sec2">Section 2</a> <a href="#sec3">Section 3</a> </div> <div class="content"> <a name="#sec1"></a> <h2>Section 1</h2> <p>Bla bla bla...</p> </div...

specialised hash table c++

I need to count a lot of different items. I'm processing a list of pairs such as: A34223,34 B23423,-23 23423212,16 What I was planning to do was hash the first value (the key) into a 32bit integer which will then be a key to a sparse structure where the 'value' will be added (all start at zero) number and be negative. Given that they...

php short hash

hello, i am looking for a php function, that creates a short hash out of a string or a file similar to those url-shortening websites like tinyurl.com the hash should not be longer than 8 characters thanks! ...

one line hash creation in ruby

How can I, very simply construct a hash in ruby using something simple like "times" I have a @date (ie = Date.today) and then a number of days... say 5 5.times { |i| @date_range[:day] = (@date+i).strftime("%Y-%m-%d") } I know there's got to be something super simple that's missing. Thanks... ...

Fastest hash code generator .NET

I'm implementing a custom GetHashCode for the System.Drawing.Point class in C#. My method currently fails the following requirement: var hashA = MyGetHashCode(new Point(1, 0)); var hashB = MyGetHashCode(new Point(0, 1)); var hashC = MyGetHashCode(new Point(0, 0)); var hashD = MyGetHashCode(new Point(1, 1)); Assert.AreNotEqual(hashA ^ ha...

php hash form string to integer

Does PHP have a built in function for doing string to integer hashes, something that's difficult to reverse? Now, I know I can probably get away with doing an md5, and treating a substring of it as a radix 16 number, but I'm looking for something built in. Thanks. ...

Using Perl to cleanup a filesystem with one or more duplicates

I have two disks, one an ad-hoc backup disk, which is a mess with duplicates everywhere and another disk in my laptop which is an equal mess. I need to backup unique files and delete duplicates. So, I need to do the following: Find all non-zero size files Calculate the MD5 digest of all files Find files with duplicate file names Separa...