hash

unique integer/long hash key generation over strings for faster compairson

I'm curious how others have solved this problem, and what problems might lurk behind the naive solution: I have a system which processes stock market data. There are tens of thousands of symbols, with associated prices/sizes, flowing into the system at the rate of several thousand every millisecond. One of the basic operations that ne...

Keeping history of hash/anchor changes in JavaScript

I'm currently implementing a JavaScript library that keeps track of the history of changes to the hash part in the address bar. The idea is that you can keep a state in the hash part, and then use the back button to go back to the previous state. In most of the recent browsers, this is automatic and you only have to poll the location.ha...

Pure-Ruby concurrent Hash

What's the best way to implement a Hash that can be modified across multiple threads, but with the smallest number of locks. For the purposes of this question, you can assume that the Hash will be read-heavy. It must be thread-safe in all Ruby implementations, including ones that operate in a truly simultaneous fashion, such as JRuby, an...

Connect to MySQL with hashed password?

Hi, I was wondering (and used Google with no clear result) if there is any way to connect to a MySQL database with PHP using a hashed password. Say I have the following: Password (plain): 'foobar' Password (sha1): '8843d7f92416211de9ebb963ff4ce28125932878' Now I would like to connect to MySQL like this (using the mysql_* function as ...

SSL authentication by comparing certificate fingerprint?

Question for all the SSL experts out there: We have an embedded device with a little web server on it, and we can install our own SSL self-signed certificates on it. The client is written in .NET (but that doesn't matter so much). How can I authenticate the device in .NET? Is it enough to compare the fingerprint of the certificate aga...

How can I reverse engineer the encode/decode method used here?

I have the page to encode and I have the page to decode. I don't, however, have the knowledge on how to do it myself without the web pages. What I'm trying to do is figure out how to encode a hoplink like: http://geoffreyf6.earth4.hop.clickbank.net into http://8e5250ieuas1d9b9bo6c6p8xat.hop.clickbank.net/ The encode/decode pages ...

(Rails) Creating multi-dimensional hashes/arrays from a data set...?

Hi All, I'm having a bit of an issue wrapping my head around something. I'm currently using a hacked version of Gruff in order to accommodate "Scatter Plots". That said, the data is entered in the form of: g.data("Person1",[12,32,34,55,23],[323,43,23,43,22]) ...where the first item is the ENTITY, the second item is X-COORDs, and t...

What's the best Perl practice for returning hashes from functions?

I am mulling over a best practice for passing hash references for return data to/from functions. On the one hand it seems intuitive to pass only input values to a function and have only return output variables. However in Perl, passing hashes can only be done by reference so it is a bit messy and would seem more of an opportunity to ...

Perl: Is there a way to split on the last regex match only?

Here's an interesting problem. Is it possible to split a string on the last matching regex only? Consider the following list of column headings from my data file (which read along the same line, being tab-separated): Frequency Min Frequency Avg Frequency Max Voltage L1 Min Voltage L1 Avg Voltage L1 Max Active Power L1 Min Active Power ...

C#: String -> MD5 -> Hex

Hi, in languages like PHP or Python there are convenient functions to turn an input string into an output string that is the HEXed representation of it. I find it a very common and useful task (password storing and checking, checksum of file content..), but in .NET, as far as I know, you can only work on byte streams. A function to do ...

How can I find the number of keys in a hash in Perl?

How do I find the number of keys in a Perl hash variable, like Perl array $#? ...

How can I access the last Perl hash key without using a temporary array?

How can I access the last element of keys in a hash without having to create a temporary array? I know that hashes are unordered. However, there are applications (like mine), in which my keys can be ordered using a simple sort call on the hash keys. Hope I've explained why I wanted this. The barney/elmo example is a bad choice, I admit,...

Ruby: split one hash into two based on desired keys

I'm hoping this question has a very simple answer. I can think of ways to do with with boring, annoying looping, but I'm hoping there's a more elegant solution. If I have the following two variables: hash = {:a => 1, :b => 2, :c => 3, :d => 4} keyset = [:a, :c] How can I get the following two hashes in the simplest way possible? has...

Are hashed and salted passwords secure against dictionary attacks?

I understand that salts make the same password hash to different values. However, salts are usually stored in the database with the password. So let's say I am attacker, here is how I might use a dictionary attack against a salt (note in this example i don't write out 128 bit hashes or salts for the sake of brevity): user_pw = 'blowfi...

What's the best way to create a short hash, similiar to what tiny Url does?

I'm currently using MD5 hashes but I would like to find something that will create a shorter hash that uses just [a-z][A-Z][0-9]. It only needs to be around 5-10 characters long. Is there something out there that already does this? Update: I like the CRC32 hash. Is there a clean way of calculating it in .NET? Update2: I'm u...

Using a hash of what you are hashing as a salt?

Say a user registers for your site, you hash the password they have chosen then use that hash as a salt and rehash their password with that salt. Example: String hash1 = MD5(password); String endHash = MD5(hash1 + password); then store endHash in your database. Would this effective agaisnt Rainbow Table attacks if my database was com...

Google using # instead of search? in URL. Why?

I'm not sure how long they've been doing it but I just noticed google using # in their search url instead of search?. New way http://www.google.com/#q=stackoverflow Old way http://www.google.com/search?q=stackoverflow The pound/hash sign is generally used as an anchor to a section of a page. Besides a shorter url what could be the bene...

Why doesn't Perl's each() iterate through the entire hash the second time?

Hi, I have a simple script trying to learn about hashes in Perl. #!/usr/bin/perl my %set = ( -a => 'aaa', -b => 'bbb', -c => 'ccc', -d => 'ddd', -e => 'eee', -f => 'fff', -g => 'ggg' ); print "Iterate up to ggg...\n"; while ( my ($key, $val) = each %set ) { print "$key -> $val \n"; last if ($val e...

Any ideas why QHash and QMap return const T instead of const T& ?

Unlike std::map and std::hash_map, corresponding versions in Qt do not bother to return a reference. Isn't it quite inefficient, if I build a hash for quite bulky class? EDIT especially since there is a separate method value(), which could then return it by value. ...

Dynamic perfect hashing and universal hash functions - explanation please?

So I'm reading up about hash tables, hash functions etc. I was intrigued to read on wikipedia about how "dynamic perfect hashing" involves using a second hash table as the data structure to store multiple values within a particular bucket. Where I get lost however, is when it comes to how a universal hash function is selected to perfor...