hash

How should I update a hash of hashes when using multi-threading in Perl?

I have been spending the last hours trying to figure this out and now I'm really confused. This is the outline of my task. I should write a Perl subroutine that gets a reference to a hash of hashes. I have another sub (helper) that gets a single inner hash and does some stuff to with, including adding keys. sub helper { $href = sh...

How is the hash value of an object stored in a dictionary?

Hey guys! Friend of mine got asked the following question in an interview recently and im looking for a definitive answer for him. How is the hash value of an object stored in a dictionary? Cheers in advance! ...

getting a unique number for the contents of a cell

I am looking for a HASH or maybe something even simpler. I want to return a unique number for every string in a cell. Does anyone know if there is a function in a cell that will return a unique number or a unique string for another string? The problem is I would like to compare whether two string are totally equal, I need to be case s...

Ruby on Rails 3 Params Hash Question

Let's say we are passing in something like :mash => true Now inside of params I want to takeit = params[:mash] What class is takeit? It's not boolean of course. Thanks for helping. ...

How do I create a simple HTML table with hyperlinks from a hash in Perl?

I have a Perl hash of "people" like this: my $data = { 124535 => { NAME => "abe", AGE => 100, SEX => "m", HOMEPAGE => qw (http://abe.knaan.old) }, 54478 => { NAME => "joe", AGE => 18, SEX => "m", HOMEPAGE => qw (http://slappy.joe.com)...

Checking 3 random letters from a hashed password

I have a system where I salt and hash passwords before saving them to the database, using FormsAuthentication in asp.net What I want to do is, rather than ask the customer for their password each time, I just want 3 random letters from their password. How can I compare this to the hash in the database? Will hashing still work in this ca...

Link to a page and execute jquery there. Need help with jquery hash and more.

Hi everyone I would be glad if some of you experts could help me with some jquery code. Thanks in advanvce for your time. I have created a page "photography.html" with a bunch of thumbnails. You can see the slideshow here: http://test.tester24.com/photography When a thumbnail is clicked, two things happen: A window with a slideshow s...

Retrieving info from hash within hash - ruby

Hey everyone, I have a quick question on retrieving information from a hash, here is the code thus far: permits_sheet.each do |row| rate_type = row[0].to_s #Converts the rate type (title) to a string row.shift #Removes the title from hash so it's not added to values row.each do |values| split_value = values.split ('=') #Refer...

Strength of hashing algorithms

I've noticed things such as MD5 has been cracked for collisions and is no longer cryptographically secure; use SHA-1 instead. SHA-1 has been cracked for collisions and is no longer cryptographically secure; use SHA-2 instead. From my current understanding, the chance of getting a certain hash h(d) from data d is equal for all hashi...

What is the time complexity for looking up an item in a Perl hash?

Suppose I have a file with n words. As I read each word in the file, I will store it in hash (in Perl). When I go back and look up for the word in the hash, what is the time complexity of looking up a string(word) in a hash? For example: my %seen = (); @arr=("one","two","three"); foreach $item (@arr){ if($seen{$item}) {//do someth...

Is there a general way of converting a hash into an two-dimensional array?

The way a hash is structed can always vary, it can be a hash of a hash of an array or whatever. And for every different struct of a hash there needs to be a different implementation of turning it into a two dimensional array. Is there a general way of converting a hash into an array? Such that i could say, for instance, first key become...

How do I push a value onto a Perl hash of arrays?

%TEST ; ... for { sub atest } sub atest { ... push $TEST { TEST1 }[0] = "some value " } How push values into Hash of arrays and dont know anything about index? How do I acheive this? ...

How to choose a salt for a hash function meant to protect passwords?

I'm a (near complete) beginner, and this is my first foray into encryption - in fact this is probably the first time I use the word. Here is my question: For a non banking / military, or even commercial, web app, what is the right way to choose a salt for a hash function used for passwords? I can easily generate a pseudo random salt f...

Is it possible to detect the key for the array within the Rails params hash?

I'm using a inherited controller for an abstracted class. I'm trying to avoid overriding actions within all of the descendant controllers. How could I find out the name of the key where the array of form values is living? For example: The master class currently uses this to update rows if @parent.update_attributes(params[:parent]) ...

How can I fetch a hash ref from array of hashes by one of its values?

I have a array of hashes, each hash containing same keys but values are unique. On the basis of particular value, I need to store hash ref. See the below example to understand it properly: my @aoaoh = ( { a => 1, b => 2 }, { a => 3, b => 4 }, { a => 101, b => 102 }, { a => 103, b => 104 }...

Python: Is there any reason *not* to cache an object's hash?

I've written a class whose .__hash__() implementation takes a long time to execute. I've been thinking to cache its hash, and store it in a variable like ._hash so the .__hash__() method would simply return ._hash. (Which will be computed either at the end of the .__init__() or the first time .__hash__() is called.) My reasoning was: "T...

md5 hash or simpler hash implemtation in android j2me

Is there any way to encrypt data passing between two android phones in j2me? Not to mention I am using BT as medium. ...

How can I delete empty arrays/refs from a Perl hash?

Lets say I have the following Perl hash: %hash = ( 'A' => { 'B' => ['C', 'D', 'E'], 'F' => { 'G' => [], 'H' => [] }, 'I' => [] } ); and I'd like to get rid of the []'s to get the hash result below: %hash = ( 'A' => [ 'B' => ['C', 'D', 'E'], 'F' => [ 'G', 'H', 'I' ] ...

Ruby Hash bug help!

I'm trying to create a Ruby Hash of objects, where the keys are the object @name member: # m is an object with an @name instance variable (a string) myHash = {} myHash[m.name] = m It's giving this error: #<TypeError: can't convert String into Integer> Anyone know why? I'm sure that m.name is a valid string... ...

mysql / file hash question

Hi, I'd like to write a script that traverses a file tree, calculates a hash for each file, and inserts the hash into an SQL table together with the file path, such that I can then query and search for files that are identical. What would be the recommended hash function or command like tool to create hashes that are extremely unlikely ...