hash

How do I interpolate a Perl hash element in a string?

How do I print a hash from within a string, as in print "\n[*] Query : $select { query }"; versus print "\n[*] Query : " . $select { query }; ...

What's the history of the + in front of a hashref that disambiguates from a code block?

I would like to read a little more about the + that is usually put in front of a hashref that helps to disambiguate from a code block. When was it first introduced? Who first introduced it (recommended it)? How did people go around the issue before this was introduced? Any trivia or notes that comes to mind while using this syntax? ...

.NET: Scalability of generic Dictionary

I'm using a Dictionary<> to store a bazillion items. Is it safe to assume that as long as the server's memory has enough space to accommodate these bazillion items that I'll get near O(1) retrieval of items from it? What should I know about using a generic Dictionary as huge cache when performance is important? EDIT: I shouldn't rely on...

php encryption sql

I want a form where user can change password. I am able to encrypt a password, however when it is selected from the database(the original password say 'test') it does not recognise it. This is when the password has been encrypted in db. i am checking to see if the typed password in form matches the one in the db: SELECT * from table wh...

Selectively counting delimited field values and creating a hash using map

I have a pipe delimited text file containing, among other things, a date and a number indicating the lines sequence elsewhere in the program. What I'm hoping to do is from that file create a hash using the year as the key and the value being the maximum sequence for that year (I essentially need to implement an auto-incremented key per y...

How are these 2 lines of PHP different?

Assuming we have a salt that's in the database and that has been generated like this $salt = time(); What is the difference between these 2 lines. $pass1 = hash('sha1', $password . $salt); $pass2 = hash_hmac('sha1', $password, $salt); They don't produce the same output. The first one, the hash function takes 2 params, while the h...

Turning a Hash of Arrays into an Array of Hashes in Ruby

We have the following datastructures: {:a => ["val1", "val2"], :b => ["valb1", "valb2"], ...} And I want to turn that into [{:a => "val1", :b => "valb1"}, {:a => "val2", :b => "valb2"}, ...] And then back into the first form. Anybody with a nice looking implementation? ...

Evernote export format (ENEX) to HTML, including pictures?

@Solved The two subquestions I have created have been solved (yay for splitting this one up!), so this one is solved. I'll award the check mark to samjudson, since his answer was the closest. For actual working solutions though, see the below subquestions; both my implemented solutions and the checked answers. @Deprecated I am splitti...

Taking a hashed URL and sending it to a new URL

For example, I'd like to have my registration, about and contact pages resolve to different content, but via hash tags: three links one each to the registration, contact and about page - www.site.com/index.php#about www.site.com/index.php#registration www.site.com/index.php#contact Is there a way using Javascript or PHP to resolve t...

How do I create and add anonymous hashes to a known Hash during script execution?

I'll attempt to illustrate this with an example. Take a common example of a Hash of Hashes: my %HoH = ( flintstones => { lead => "fred", pal => "barney", }, jetsons => { lead => "george", wife => "jane", "his boy" => "elroy", }, simpsons => { lead => "homer",...

Can I construct a BigInt with any byte array (Scala)?

I'm trying to represent the result of an MD5 hash in the shortest possible string. It seems a waste to just turn it into a hex string and let G through Z go to waste. One idea I have had is getting the MD5 hash of my input as an array of bytes and constructing a BigInt with it. I can then call toString(36), and get the number as a base-...

Quick and Simple Hash Code Combinations

Can people recommend quick and simple ways to combine the hash codes of two objects. I am not too worried about collisions since I have a Hash Table which will handle that efficiently I just want something that generates a code quickly as possible. Reading around SO and the web there seem to be a few main candidates: XORing XORing wi...

Is it okay to store salts with hashes?

My understanding is that a salt is not intended to be secret, it is merely intended to be different from any centralized standard so that you can't develop a rainbow table or similar attack to break all hashes that use the algorithm, since the salt breaks the rainbow table. My understanding here might not be completely correct, so corre...

Case-insensitive Bob Jenkins Hash?

Is there a case-insensitive variant of the Bob Jenkins hash function? Generics.Defaults.BobJenkinsHash provides a fast hash function. Unfortunately it cannot be used in combination with a case-insensitive compare function like so TCustomStringComparer = class (TEqualityComparer <String>) function Equals(const Left, Right: String): ...

Using # in links instead of GET params = faster?

I just noticed that say http://s7.addthis.com/js/250/addthis%5Fwidget.js#pub=PUBID does the equivalent of http://s7.addthis.com/js/250/addthis%5Fwidget.js?pub=fct-250 but is much faster. How does that work? O_o I'm including the above links in a < script src call. Its supposedly faster according to one of the addthis developers. ...

Question on logistics of hashing at client

I have found a lot of posts on hashing at the client but none that quite answer my question. I would like to hash user passwords at the client so that I don't have to send a plain text password across the web but I have a question as to how i might do so successfully when using a salt. The normal procedure of validating a password is.....

Ruby password SHA512 hash replication using PHP

Hi there, is there any way I can reproduce this ruby function: def Password.hash(password,salt) Digest::SHA512.hexdigest("#{password}:#{salt}") end In php. Cheers ...

What is a good 64bit hash function in Java for textual strings?

I'm looking for a hash function that: Hashes textual strings well (e.g. few collisions) Is written in Java, and widely used Bonus: works on several fields (instead of me concatenating them and applying the hash on the concatenated string) Bonus: Has a 128-bit variant. Bonus: Not CPU intensive. ...

appending to hash while looping

I will make this quick. I'm using Ruby/LDAP to search using my base_dn criteria. I get a result back (of type Entry). I can convert object of type Entry to Hash with to_hash method. The problem is when the result is returned it is multiple objects of type Entry. I want to convert them to hash append them while looping. Look at this: co...

Optimizing word count

(This is rather hypothetical in nature as of right now, so I don't have too many details to offer.) I have a flat file of random (English) words, one on each line. I need to write an efficient program to count the number of occurrences of each word. The file is big (perhaps about 1GB), but I have plenty of RAM for everything. They're...