hash

Fastest hash function(ASP.NET) for hashing filenames

I'm trying to optimize my ASP.NET thumbnailing script, so it doesn't resize all the images all the time, and one part of the problem is choosing the hash function for the thumbnail naming/checking procedure. Is crc32 up to the task - I'm asking cause the input data is small(only relative path, size and date)? ...

Is this login scheme secure ?

Here is what I got for a webapp login scheme. Present in database would be two salts and hmac(hmac(password, salt1), salt2). When the user go on the login page, he gets salt1. If he has javascript activated, instead of sending the plaintext password, it would send hmac(password, salt1). If he does not have javascript, the plaintext pass...

MD5 Hashes failing for large Strings

I'm making a MD5 hash of a response, and then signing it with a shared secret. For most calls this works, but strangely fails (Generates a MD5 hash different from the client) on the only two calls that bring a lot of content in the body. Can this be because of the size of the body? or maybe because those calls return the content chunk...

How can i render a json response from a hash while maintaining order in ruby on rails?

hey out there, i am failing to render a json response in ruby on rails from a hash datastructure of country-names with their country-codes: { "AF"=>"Afghanistan", "AL"=>"Albania", "DZ"=>"Algeria", ... }, so that the json response has its entries alphabetically ordered like this: { "AF":"Afghanistan", "AL":"Albania", "DZ"=>"Algeria" ... ...

Youtube URL-style hashes

Hello, I'm trying to find out how to build nice and short alpha numeric hashes like the kind used in youtube urls. Example: http://www.youtube.com/watch?v=rw71YOSXhpE Where rw71YOSXhpE would convert into video number 12834233 (for example). These integers could be reversed in PHP to an integer and then looked up in a database. I've ...

How to write a hash function in C?

Hash Tables are said to be the fastest/best way of Storing/Retrieving data. My understanding of a hash table, hashing is as follows (Please correct me if I am wrong or Please add If there is anything more): A Hash Table is nothing but an array (single or multi-dimensional) to store values. Hashing is the process to find the index/loca...

Retrieving specific hash key values from an array of hashes

All, I was wondering if anyone knew a better patten than: array_of_hashes.map { |hash_from_array| hash_from_array[:key] } for retrieving an array of values with a specific key from an array of hashes containing that key. ...

extracting specific value from a multidimensional hash in ruby by key name

let's say i have a multidimensional hash, and in one of the subhashes i have a key=>value pair which i need to retrieve by key. how can i do it? example hashes: h={:x=>1,:y=>2,:z=>{:a=>{:k=>"needle"}}} h={:k=>"needle"} key is always :k, and i need to get "needle" i noticed that there is no "flatten" function for hashes in ruby 1.8, ...

How well does .NET dictionary resolve collisions?

I have a problem with a custom object that needs to be keyed for a table. I need to generate a unique numeric key. I'm having collision problems and I'm wondering if I can leverage a dictionary to help me. Assume I have an object like this: class Thingy { public string Foo; public string Bar; public string Others; } and so...

Actionscript one way encryption

Hi all. Is there a built in method in Actionscript 3 that allows you to create a hash of a string. Like MD5 and SHA1. Thanks. ...

Is there a significant overhead by using different versions of sha hashing (hashlib module)

The hashlib Python module provides the following hash algorithms constructors: md5(), sha1(), sha224(), sha256(), sha384(), and sha512(). Assuming I don't want to use md5, is there a big difference in using, say, sha1 instead of sha512? I want to use something like hashlib.shaXXX(hashString).hexdigest(), but as it's just for caching, I'...

How do I search within an array of hashes by hash values in ruby?

Hi, I have an array of hashes, @fathers. a_father = { "father" => "Bob", "age" => 40 } @fathers << a_father a_father = { "father" => "David", "age" => 32 } @fathers << a_father a_father = { "father" => "Batman", "age" => 50 } @fathers << a_father How can I search this array and return an array of hashes for which a block returns...

How can I create a unique 7-digit code for an entity?

When a user adds a new item in my system, I want to produce a unique non-incrementing pseudo-random 7-digit code for that item. The number of items created will only number in the thousands (<10,000). Because it needs to be unique and no two items will have the same information, I could use a hash, but it needs to be a code they can sh...

How do I copy an array using a reference in Perl?

If I do the following, it works fine: print $ref->{element}->[0]->{data}; I would like to see how many references are in the array so that I can loop through them, but I am having a hard time doing that. Here is the code I have tried, but it doesn't work: my @array = @$ref->{element}; foreach(@array) { print $_->{data}; } I ...

Using hash characters in 'pretty urls'

I haven't found a good resource in using # in urls to enable bookmarking with ajax calls so I have a few questions. We have a site based on CakePHP using 'pretty' urls essentially www.mysite.com/controller/action/param1:param2 I noticed that Facebook uses a weird syntax with their pretty urls ex) #!/?ref=logo Is there a way we can use ...

Shortening/Rehashing UUIDs

Hi, first of all, I want to assure that I'm aware of the fact, that rehashing is a sensible topic. However I'd like to hear some opions of you, what approach you would take here. I'm building a distribured application, where nodes remotely create entities identified by a UUID. Eventually, all entities should be gathered at a dedicated ...

PHP best way to MD5 multi-dimensional array?

Hi, i was wondering what is the best way to generate an MD5 (or any other hash) of a multi-dimensional array? I could easily write a loop which would traverse through each level of the array, concatenating each value into a string, and simply performing the MD5 on the string. However, this seems cumbersome at best and i wondered if t...

JAVA--how to parse a JSON and turn its values into an Array?

public static void parseProfilesJson(String the_json){ try { JSONObject myjson = new JSONObject(the_json); JSONArray nameArray = myjson.names(); JSONArray valArray = myjson.toJSONArray(nameArray); for(int i=0;i<valArray.length();i++) { String p = nameArra...

How do I dereference a hash that's been returned from a method of a class?

I have a class with a method that returns a hash. Ordinarily, I would get the result like so: %resp = $myclass->sub($foo); And then access members of the returned hash like this: $resp{key}{subkey}; in the case of a 2d hash. I figure there must be a way to combine this into a single, elegant line, something like this: $myclass->...

hash functions family generator in python

Hi, I am looking for a hash functions family generator that could generate a family of hash functions given a set of parameters. I haven't found any such generator so far. Is there a way to do that with the hashlib package ? For example I'd like to do something like : h1 = hash_function(1) h2 = hash_function(2) ... and h1 and h2 would...