hash

How do I access random element in a Perl DBM hash?

I have a Perl DBM hash containing a list of URLs that I want to pick randomly from to load balance spidering sites. As a result I want to pick a key at random, or select the nth element (so I can randomise n). I'm aware this goes against the concept of a hash, but is this possible? NOTE: missed a valuable point that hash size will be ...

Secure Token Process

Im currently in the mist of developing a website using PHP and MYSQL. Its a private website therefore registrations must allowed using emails. In simple tearms if a new user has to be registered. The administrator has to go into the system and add an email address to be registered. What i want to create is a token or a pass value when t...

Strange Python set and hash behaviour - how does this work?

I have a class called GraphEdge which I would like to be uniquely defined within a set (the built-in set type) by its tail and head members, which are set via __init__. If I do not define __hash__, I see the following behaviour: >>> E = GraphEdge('A', 'B') >>> H = GraphEdge('A', 'B') >>> hash(E) 139731804758160 >>> hash(H) 139731804760...

Boo: Explicitly specifying the type of a hash

I am new to Boo, and trying to figure out how to declare the type of a hash. When I do: myHash = {} myHash[key] = value (later) myHash[key].method() the compiler complains that "method is not a member of object". I gather that it doesn't know what type the value in the hash is. Is there any way I can declare to the compil...

Ruby Hash & Array to xml

I'm using ActiveSupport's to_xml to generate some xml from a hash. I have need for the this ruby: :Shipment => { :Packages => [ {:weight => '5', :type => 'box'}, {:weight => '3', :type => 'tube'} ] } To generate this xml: <Shipment> <Package> <weight>5</weight> <type>box</type> </Package> <Package> <wei...

How to access url hash/fragment from a Django Request object

As in the title: how can I access the url hash/fragment (the part following the dash #) from a Django view and so, I suppose, from a Django Request object? I've not found enough information on the documentation here available: http://docs.djangoproject.com/en/dev/ref/request-response/ P.S. Suppose that the fragment part is sent to the ...

MD5 Signing a HttpServletResponse

I'm looking for a way to inspect the contents of a HttpServletResponse to sign them with a MD5 hash. The pseudocode might look like this process(Response response, Request request){ defaultProcessingFor(response,request); dispatcher.handle(response,request); // Here I want to read the contents of the Response object (now filled wit...

Help with salt and passwords

I want to implement a salt into my login system but am a bit confused on how this is supposed to work. I can't understand the logic behind it. I understand md5 is a one-way algorithm and all of the functions that I have come across seem to hash everything together. If this is the case, how does one get the password back out for compariso...

Can i use the ordering methods of simple linked lists into a hash list?

Im confused with this question? Thank you in advance. Programming in C under linux ...

Should I cache the hash code of an STL string used as a hash key?

I've doing some performance analysis on the software I develop, and I've found that lookups on a global dictionary of URL's takes about 10% of the application's "load" phase time. The dictionary is implemented as a C++ STL std::map, which has O(lg n) lookups. I'm going to move it to a hash_map, which has roughly fixed time lookups. Th...

Write an anonymous sub in Perl to a file for later use.

I have a Perl program that generates parsing rules as subs from an input file. The subs are anonymously defined an put into a hash. Now, I want to export that hash, with all the subs and then load them again later to use with a different program. How do I go about doing this? Is there some way to extract the code of each sub, or can ...

Rails Hash with several object attributes. How do I save them all?

I get hash from a fields_for that looks like this: "affiliation_attributes"=>{ "11"=>{"volunteer_id"=>"14", "affiliationtype_id"=>"1", "organization_id"=>"1"}, "1"=>{"volunteer_id"=>"1", "affiliationtype_id"=>"3", "organization_id"=>"1"}, "4"=>{"volunteer_id"=>"2", "affiliationtype_id"=>"3", "organization_id"=>"1"}, "21"=>{"volunte...

Visual basic 6.0 - ComputeHash invalid procedure call or argument error

I am getting the error "invalid procedure call or arguments" at the step computeHash(). Any help highly appreciated. Private Sub Form_Load() Dim rngcsp As New RNGCryptoServiceProvider '= new RNGCryptoServiceProvider() Dim u8 As Encoding 'u8 = Encoding.UTF8 Dim minSaltSize As Integer Dim maxSaltSize As Integer Dim saltSize As Inte...

Is built in ASP.NET Membership Hashing good enough?

I'm just wondering if the built in Hashing in the ASP.Net membership good password security, or if there is more that I should do to protect my passwords? If so, what should I look into for a higher level of security? ...

Need memory efficient way to store tons of strings (was: HAT-Trie implementation in java)

I am working with a large set (5-20 million) of String keys (average length 10 chars) which I need to store in an in memory data structure that supports the following operation in constant time or near constant time: // Returns true if the input is present in the container, false otherwise public boolean contains(String input) Java's ...

Difference between a keyed hash and a non-keyed hash?

I've read a few articles about cryptography in .net, which leads me to the following question, what is the difference between a keyed hash and a non-keyed hash? ...

What is the correct format for a blowfish salt using PHP's crypt?

I have read the information provided on the PHP Manual Entry for crypt(), but I find myself still unsure of the format for a salt to trigger the Blowfish algorithm. According manual entry, I should use '$2$' or '$2a$' as the start of a 16 character string. However, in the example given later, they use a much longer string: '$2a$07$uses...

Why does crypt/blowfish generate the same hash with two different salts?

This question has to do with PHP's implementation of crypt(). For this question, the first 7 characters of the salt are not counted, so a salt '$2a$07$a' would be said to have a length of 1, as it is only 1 character of salt and seven characters of meta-data. When using salt strings longer than 22 characters, there is no change in the ...

Speclialized hashtable algorithms for dynamic/static/incremental data

I have a number of data sets that have key-value pattern - i.e. a string key and a pointer to the data. Right now it is stored in hashtables, each table having array of slots corresponding to hash keys, and on collision forming a linked list under each slot that has collision (direct chaining). All implemented in C (and should stay in C)...

Python MD5 not matching md5 in terminal

Hey guys, am getting MD5 of several files using python function filehash = hashlib.md5(file) print "FILE HASH: " + filehash.hexdigest() though when I go to the terminal and do a md5 file the result I'm getting is not the same my python script is outputting (they don't match). Any chance someone knows why? Thanks. ...