hash

How to check uniqueness of many-to-many collection?

Here's the desired flow of my PHP app (yes, it's vague, but it's easier that way): User submits a set of, let's say, about 5 objects by integer IDs. (It'll really be more like 15, but let's say 5 for ease.) App checks if this collection has been submitted before, and saves it in a MySQL database if not App saves these objects in the da...

Hash quality and stability of String.GetHashCode() in .NET?

I am wondering about the hash quality and the hash stability produced by the String.GetHashCode() implementation in .NET? Concerning the quality, I am focusing on algorithmic aspects (hence, the quality of the hash as it impacts large hash-tables, not for security concerns). Then, concerning the stability, I wondering about the poten...

Very simple password generation scheme; is this secure?

Edit/clarification: I mean password generation as in "deterministically generate passwords for your own use (e.g. to sign up for web services), based on some secret and on some site-specific data" I take the MD5 digest of the concatenation of my master password and a (non-secret) site-specific string. Then I take the first 16 digits of ...

Is it a bad idea to use recordId as hashcode?

Suppose I have a simple DTO object right out of the database, and the Id is a recordId that is definitely unique, is it a good idea then to do the following ? public class DTO { public int Id { get; set; } public override bool Equals(object obj) { return (Id == ((DTO)obj).Id); } public override int GetH...

Data structure for efficiently returning the top-K entries of a hash table (map, dictionary)

Here's a description: It operates like a regular map with get, put, and remove methods, but has a getTopKEntries(int k) method to get the top-K elements, sorted by the key: For my specific use case, I'm adding, removing, and adjusting a lot of values in the structure, but at any one time there's approximately 500-1000 elements; I want ...

Is there a built in function to hash passwords in .NET?

I seen this question http://stackoverflow.com/questions/287517/encrypting-hashing-plain-text-passwords-in-database and i am aware i shouldnt do md5("salt" + password); and i see an implementation in python for a solution. Is there a .NET built in function with params i can use instead of writing my own? ...

Possible to calculate MD5 (or other) hash with buffered reads ?

I need to calculate checksums of quite large files (gigabytes). This can be accomplished using the following method: private byte[] calcHash(string file) { System.Security.Cryptography.HashAlgorithm ha = System.Security.Cryptography.MD5.Create(); FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Rea...

how to convert a hash into an array with particular order? (ruby)

I have a hash of hashes (@post) and I want to save it into csv. Strange for me is that my approach works for the header but not for the rows. If I display the rows using csv << (@post_csv_order.each {|element| puts single_post[element]}) I can see the right strings on the screen but the csv files contains values of the hash key not t...

How can I determine if a Perl hash contains a key mapping to an undefined value?

I need to determine if a Perl hash has a given key, but that key will be mapped to an undef value. Specifically, the motivation for this is seeing if boolean flags while using getopt() with a hash reference passed into it. I've already searched both this site and google, and exists() and defined() don't seem to be applicable for the si...

Assigning Each User a Unique 100 character Hash in Ruby on Rails

I have a form on a website that takes in some personal information from the visitor. I'm passing this information to another service and I need to assign each one of these form submits a 100 character unique hash to be stored in the DB with the record. What's the optimal way to generate this key and make sure it's unique? It's okay if...

Lua's hybrid array and hash table; does it exist anywhere else?

Lua's implementation of tables keep its elements in two parts: an array part and a hash part. Does such a thing exist in any other languages? Take a look at section 4, Tables, in The Implementation of Lua 5.0. Lua 5.1 Source Code - table.c ...

hash assignment when (key => value) are stored in an array? (ruby)

I have hash (@post) of hashes where I want to keep the order of the hash's keys in the array (@post_csv_order) and also want to keep the relationship key => value in the array. I don't know the final number of both @post hashes and key => value elements in the array. I don't know how to assign the hash in a loop for all elements in th...

Pseudorandom seed methodology for lookup tables

Could someone please suggest a good way of taking a global seed value e.g. "Hello World" and using that value to lookup values in arrays or tables. I'm sort of thinking like that classic spacefaring game of "Elite" where there were different attributes for the planets but they were not random, simply derived from the seed value for the ...

How to get the size of each value of a hash

hi! I have a hash, each value is an array. I want to build a new array containing the size of each value/array. Example: the hash {"A"=>["1", "2", "3"], "B"=>["b", "toto"]} the result [3, 2] thanks for your help ...

String hashing with linear probing

Hello, I am stuck trying to figure out how to do string hashing with linear probing. Basically, the idea is to hash every string from a dictionary (90000 words), and retrieve anagrams of selected words. Here's what I did: created a hash table 2*90000 in size using a simple hash function, I hash each word from the dictionary, get a v...

Ruby 1.9 hash with a dash in a key

In ruby 1.9 there is a way to define this hash with the new syntax? irb> { a: 2 } => {:a=>2} irb> { a-b: 2 } SyntaxError: (irb):5: syntax error, unexpected tLABEL { a-b: 2 } ^ with the old one, it's working: irb> { :"a-b" => 2 } => {:"a-b"=>2} ...

Hash and salt passwords in C#

I was just going through one of DavidHayden's articles on Hashing User Passwords. Really I can't get what he is trying to achieve. Here is his code: private static string CreateSalt(int size) { //Generate a cryptographic random number. RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buff = new byte[si...

Guessing the hash function?

I'd like to know which algorithm is employed. I strongly assume it's something simple and hopefully common. There's no lag in generating the results, for instance. Input: any string Output: 5 hex characters (0-F) I have access to as many keys and results as I wish, but I don't know how exactly I could harness this to attack the functio...

Using hash of password with SSL

OK this might sound like a strange question. Please read carefully before jumping on me OK? ;-) Imagine this situation: We have a server and a client. They connect using SSL. Client creates account on server with password. But, what he actually passes to server over the wire is the hash (+salt) of the password (NOT the password) Ser...

Using Skein for File integrity checking.

Hi Id like to know that is it possible to use skein instead of MD5 or SHA1 for file integrity checking? How? Is that really better or faster than SHA1 and MD5?Explain please. ...