hashing

A PHP hash function with a long output length?

Inside my code I'm generating hashes of URLs, (which are practically of unbounded length). I'm currently using sha1(), which I know has a tiny chance of a collision, but I have up to 255 bytes to store the hash in so feel that I might as well use that available space to lower the chance of collision even further. Is there either: Ano...

How come MD5 hash values are not reversible?

Hey everyone, One concept I've always wondered about is the use of cryptographic hash functions and values. I understand that these functions can generate a hash value that is unique and virtually impossible to reverse, but here's what I've always wondered: If on my server, in PHP I produce: md5("stackoverflow.com") = "d0cc85b26f2ceb87...

Detecting if two images are visually identical

Sometimes two image files may be different on a file level, but a human would consider them perceptively identical. Given that, now suppose you have a huge database of images, and you wish to know if a human would think some image X is present in the database or not. If all images had a perceptive hash / fingerprint, then one could hash ...

Most efficient sorting algorithm for many identical keys?

What is the most efficient algorithm for grouping identical items together in an array, given the following: Almost all items are duplicated several times. The items are not necessarily integers or anything else that's similarly simple. The range of the keys is not even well-defined, let alone small. In fact, the keys can be arbitrar...

Remove duplicate items with minimal auxillary memory?

What is the most efficient way to remove duplicate items from an array under the constraint that axillary memory usage must be to a minimum, preferably small enough to not even require any heap allocations? Sorting seems like the obvious choice, but this is clearly not asymptotically efficient. Is there a better algorithm that can be d...

MD5 Hashing in Delphi 2009

In borland delphi 7 and even in delphi 2007 everything worked, but in delphi 2009 it just returns the wrong hash! I use wcrypt2 script (http://pastebin.com/m2f015cfd) Just have a look: string : "123456" hash: Delphi 7 : "e10adc3949ba59abbe56e057f20f883e" - real hash. Delphi 2007 : "e10adc3949ba59abbe56e057f20f883e" - real hash too....

Secure hash and salt for PHP passwords

It is currently said that MD5 is partially unsafe. Taking this into consideration, I'd like to know which mechanism to use for password protection. Is “double hashing” a password less secure than just hashing it once? Suggests that hashing multiple times may be a good idea. How to implement password protection for individual files? Sug...

Cleanest way to create a Hash from an Array

I seem to run into this very often. I need to build a Hash from an array using an attribute of each object in the array as the key. Lets say I need a hash of example uses ActiveRecord objecs keyed by their ids Common way: ary = [collection of ActiveRecord objects] hash = ary.inject({}) {|hash, obj| hash[obj.id] = obj } Another Way: ...

Should a .NET generic dictionary be initialised with a capacity equal to the number of items it will contain?

If I have, say, 100 items that'll be stored in a dictionary, should I initialise it thus? var myDictionary = new Dictionary<Key, Value>(100); My understanding is that the .NET dictionary internally resizes itself when it reaches a given loading, and that the loading threshold is defined as a ratio of the capacity. That would suggest ...

Determining if a position is free in a Closed Hashing.

How would you go about determining whether a position is already occupied or not? When the memory is allocated, all that there is in it is garbage (in C++, which is what I'm using atm). I was thinking of using an auxiliary array of bools to know whether the position is occupied, but that would demand quite a lot of additional memory. I ...

Explanation about hashing and its use for data compression

Hello, I am facing an application that uses hashing, but I cannot still figure out how it works. Here is my problem, hashing is used to generate some index, and with those indexes I access to different tables, and after I add the value of every table that I get using the indexes and with that I get my final value. This is done to reduce...

C# and SQL Server: Passwords. Where to do what?

Ok, I have an application written in C#. We have data in an SQL Server. Among that data we have user accounts, which will give access to the application. I've read around, and I know that you should salt and hash and possibly hash a bunch of times, etc. But, where do I do what? What do I send to and from the SQL Server? Exactly what do ...

C#: BCrypt implementation

I have read that when hashing a password, many recommend using the BCrypt algorithm. I am programming in C# and is wondering if anyone know of a good and correct implementation. Found this page here, with one, but I don't really know if it is bogus or not. Although, to a non crypting expert, the code looks kind of impressive and comples ...

Is there a well-regarded library I can use to hash passwords and authenticate users for a WPF app?

There's a number of posts here on hashing of passwords and numerous recommendations on how to go about doing it, but before I go off and write something based on the suggestions here, is there a standard library I can use to save me some time (and potentially blushes, knowing how complex this stuff can be). My criteria is it has to work...

Linux: compute a single hash for a given folder & contents?

Surely there must be a way to do this easily! I've tried the linux command-line apps sha1sum & md5sum but they seem only to be able to compute hashes of individual files and output a list of hash values, one for each file. I need to generate a single hash for the entire contents of a folder (not just the filenames). I'd like to do s...

Loading a model into a half-edge data structure from a .PLY file

I am attempting to build a .PLY parser to load 3d models stored as .ply files into a half edge data structure mesh. Sorry for the huge question, I'm very verbose and I wanted to make sure I laid out all the details. Because of this, I'll restate my ultimate goals immediately, just so users can see can get an idea of what i want before ...

What are the security concerns when passing a hashed password around?

I have a Silverlight control on a web page and would like to pass the username and the hashed password to this control as part of the InitParams. What are the security concerns with doing this? The user has to log in to get to this page. However, I'm guessing that the browser might cache the page with the Silverlight control and this w...

Hash validation periodic failures

We use hash validation to prevent cookie tampering. I've been tracking false positives -- cookies in the request that fail validation but show no signs of tampering -- and typically we see a handful of failures per hour. However, we have also seen our sites experience periods where every request fails the hash check. We're in an extended...

Best general-purpose digest function?

When writing an average new app in 2009, what's the most reasonable digest function to use, in terms of security and performance? (And how can I determine this in the future, as conditions change?) When similar questions were asked previously, answers have included SHA1, SHA2, SHA-256, SHA-512, MD5, bCrypt, and Blowfish. I realize that...

What to use for password hashing? Any reason not to use jBCrypt?

I'm planning to use jBCrypt for password hashing in a new web application, as it is supposed to be the best from what I've read. As I haven't used it before I'm looking into if there is any reason not to use it. I have this: I haven't found it in the Maven repository (searched for jbcrypt and bcrypt at mvnrepository.org) which is a do...