hash

Why can't I use the map function to create a good hash from a simple data file in Perl?

The post is updated. Please kindly jump to the Solution part, if you've already read the posted question. Thanks! Here's the minimized code to exhibit my problem: The input data file for test has been saved by Window's built-in Notepad as UTF-8 encoding. It has the following three lines: abacus æbәkәs abalone æbәlәuni abandon әbænd...

Comparing ruby hashes

Hi I have two ruby hashes (which are essentially models) and am trying to find the differences between them, one is an old instance of an object where the other has new values assigned to some attributes. I'm trying to determine which keys have changed, but there doesn't seem to be anything built into the Hash for this. I can think of...

Anagram Hash Function

I know something like this has been asked before, but the answer was sort of side tracked. I want to develop a hash function which will take a word and spit out an address of an array. So, for example, if you input god: sort the word, d o g perform some sort of function on this to get an address d o g -> some number insert 'dog' into...

Password hashing at client browser

What's the best way to hash the user password at the client browser, before sending it to the web server, so that only the hash goes out, not the plain-text password? EDIT: assuming HTTP is used (not HTTPS) ...

How are CouchDB Document ID's Calculated?

How are the CouchDB Document ID's calculated? BA1F48C5418E4E68E5183D5BD1F06476 Thanks! ...

Convert 32-char md5 string to integer

What's the most efficient way to convert an md5 hash to a unique integer to perform a modulus operation? ...

Convert XML collection (of Pivotal Tracker stories) to Ruby hash/object

I have a collection of stories in an XML format. I would like to parse the file and return each story as either hash or Ruby object, so that I can further manipulate the data within a Ruby script. Does Nokogiri support this, or is there a better tool/library to use? The XML document has the following structure, returned via Pivotal Tra...

How do I get a hash slice from a hash of hashes?

I have a hash like so: my %h = ( a => { one => 1, two => 2 }, b => { three => 3, four => 4 }, c => { five => 5, six => 6 } ); print join(',', @{$h{a}{qw/one two/}}); The error I get is: Can't use an undefined value as a...

Convert Perl script to Python: dedupe 2 files based on hash keys

I am new to Python and would like to know if someone would kindly convert an example of a fairly simple Perl script to Python? The script takes 2 files and outputs only unique lines from the second file by comparing hash keys. It also outputs duplicate lines to a file. I have found that this method of deduping is extremely fast with Pe...

Dictionary with two hash functions in C# ?

I've got a huge (>>10m) list of entries. Each entry offers two hash functions: Cheap: quickly computes hash, but its distribution is terrible (may put 99% of items in 1% of hash space) Expensive: takes a lot of time to compute, but the distribution is a lot better also An ordinary Dictionary lets me use only one of these hash functio...

Assign 10-digit char user ids to 1 of 1000 servers.

Hi -- Looking to shard a database and to assign different users to different home servers based on their user id. User IDs are 10 character strings, e.g., "f4gKUKkj91" ... each server has an ID of 1 - 1000. How can I create a hash function in php to uniquely and consistently assign each user id to a specific shard ? If the user id were...

Which hash to use for file uniqueness in Java

I'm trying to keep track of a set of files, which may have the same name and metadata. I'd like to use a hash to differentiate and use it as a unique ID, but I'm not sure which one to use? The files are relatively small (in the 100 kb range) and I'd like to be able to hash that in less than 10 seconds. Which hash (that comes built in ...

How do I access the array's element stored in my hash in Perl?

# I have a hash my %my_hash; # I have an array @my_array = ["aa" , "bbb"]; # I store the array in my hash $my_hash{"Kunjan"} = @my_array; # But I can't print my array's element print $my_hash{"Kunjan"}[0]; I am new to Perl. Please help me. ...

How does this PHP nonce library work?

From http://fullthrottledevelopment.com/php-nonce-library#download, there is a PHP nonce library, but there are a few things that I don't know understand. The first one is that it reminds us to set a value for the FT_NONCE_UNIQUE_KEY but it never uses it in any of its functions. The second thing is, when I call the ft_nonce_create_query...

Is the value returned by ruby's #hash the same across interpreter instances?

Is the value returned by ruby's #hash the same across interpreter instances? For example, if I do "some string".hash, will I always get the same number even if run in different instances of the interpreter? If so, is this also true for all the builtin types (e.g. Hash, FixNum, etc). ...

Using a hash function to give a memorable personality to objects

(Note: The project is in Python.) I'm running a simulation in which I have many objects that I want to show on the screen and manipulate with. There needs to be a way to identify each object, because they'll be moving from place to place abruptly and I want to be able to track which object moved where. What I've been thinking is, to ev...

Rails storing host password for FTP model

I'm building a rails app that communicates with other servers via ftp. The user needs to input their host, username and password for their particular ftp server. I wouldn't want to store their password as cleartext, but I need the actual password to connect to the server when it comes time. Would it make sense to use a two-way hash? ...

Restricting user password character set

Working on a login system - the point where customer chooses their password for site access. Beyond using RegEx to ensure that the password is strong enough, normally on our system all data that will wind up in the database is checked against injection etc and a reasonably restricted character set is enforced on all fields. I don't rea...

Is this snippet creating an anonymous Perl hash?

While reading the snippets provided by FormFiller ( where I kinda got by accident ) , I noticed this line: $f->add_filler( password => Interactive => []); Is this password => Interactive => [] equivalent to {"password" => {"Interactive"=>[]}}? If not, what does it become? ...

What's the difference between a hash and hash reference in Perl?

I would like to properly understand hashes in Perl. I've had to use Perl intermittently for quite some time and mostly whenever I need to do it, it's mostly related to text processing. And everytime, I have to deal with hashes, it gets messed up. I find the syntax very cryptic for hashes A good explanation of hashes and hash references...