hash

Efficient ways of telling whether or not a string/file has changed - crc32? md5? something else?

I'm looking for an efficient way to tell whether or not a string (or a file) has changed since the last time we looked at it. So, we run this function against 1,000,000 files/strings (each file/string is less than 1000 bytes), and store the output for each file/string. I'll then wait a few days and run this again. I need to find out ...

Is it a bad idea to send the hash of a password instead of the unhashed password?

For example, if the user has JavaScript enabled, we send hash his password and send the hash. If not, we send the password unhashed and a flag to mark that it is unhashed. We then build the hash (if it's unhashed) and compare it to the stored hash. This seems to be secure and simple. Why isn't it a popular way to send a password? Did I ...

How can I use an existing array as a value in a hash in Perl?

I have an existing array I wish to add as a value in a hash. I know you can use arrays as values but can see no way of assigning an existing one. I basically want to go: $hash{fieldName} = @myArray; Only that obviously doesn't work! Help appreciated! ...

How to Store Passwords in Databases and Cookies (PHP/MySQL)

Hi, Having read this article and many others out there on how to not store passwords in databases and cookies, I'm wondering now how I should do it... What I've come up so far (after reading around a bit) is taking the clear-text user password, padding it with salt till it fills up 512 bits (64 bytes => 64 chars, since the page is non-...

Hashed passwords and the entity framework

I've got a Users table and the HashedPassword column is of the binary(16) type. It's used to store an MD5 hash. To generate the hash I created a couple of stored procedures: CreateUser, EditUser and LoginUser. They have a parameter that accepts a password in plaintext, convert it to the MD5 hash and store/lookup the hash in the table. T...

Generating an XML document hash in C#

What's the best way to go about hashing an XML document in C#? I'd like to hash an XML document so that I can tell if it was manually changed from when it was generated. I'm not using this for security--it's OK if someone changes the XML, and changes the hash to match. For example, I'd hash the child nodes of the root and store the hash...

How do a use a SecureString to create a SHA1 or SHA512 Hash?

I would like to use a SecureString varible within VB.NET and convert that to a SHA1 or SHA512 hash. How would I securely convert the SecureString to the Byte array that HashAlgorithm.ComputeHash will accept? ...

Good hash function for permutations?

I have got numbers in a specific range (usually from 0 to about 1000). An algorithm selects some numbers from this range (about 3 to 10 numbers). This selection is done quite often, and I need to check if a permutation of the chosen numbers has already been selected. e.g one step selects [1, 10, 3, 18] and another one [10, 18, 3, 1] the...

Java Equivalent to Python Dictionaries

I am a long time user of Python and really like the way that the dictionaries are used. They are very intuitive and easy to use. Is there a good Java equivalent to python's dictionaries? I have heard of people using hashmaps and hashtables. Could someone explain the similarities and differences of using hashtables and hashmaps versus pyt...

Pure Python persistent key and value based container (a hash like interface) with large file system support?

I am looking for a (possibly) pure Python library for persistent hash table (btree or b+tree which would provide following features Large file support (possibly in terabytes) Fast enough and low memory footprint (looking for a descent balance between speed and memory) Low cost of management Reliability i.e. doesn't corrupt file once th...

Caching data vs. writing in memory table

Which would be the best way to achieve a fast hash / session storage with one of these three ways? Way 1: Create a memory table in MySQL that stores a hash and a timestamp when the entry was created. A MySQL event automatically deletes all entries older than 20 minutes. This should be pretty fast because all data is stored in memory, bu...

Python way to do crc32b

Hi all! As i posted as title, there is a way to use the crc32b hash on python natively or through a library (i.e. chilkat)? My intention is to "translate" a program from php to python, so output should be same as in php: $hashedData= hash('crc32b',$data); -> Edit: in a win32 system Thanks to all ;) ...

Hashing-algorithm for dates

What would be a good hash-algorithm to hash dates, e.g. 24/12/09 and 31/10/89? The dates would range from about year 1950 to 2050. Could using the unix timestamp somehow, be possible? ...

How can I maintain the order of keys I add to a Perl hash?

how to maintain the order of actual list after counting its occurence using hash... in the following program... eg.. <DATA> are a b e a c d a c d b etc.... Using hash... i counted the occurence of each element. and what i want is: a 3 b 2 e 1 c 2 d 2 but the following program shows me otherwise... my (%count, $line, @array...

compare Hash with Binary search tree

Hi, We all know that a hash table has O(1) time for both inserts and look-ups if the hash function was well chosen. So, what are the reason we want to use Binary Search Tree? Just because a perfect hash function was hard to design? Here how I come up with this question? I notice that Standard C++ STL has set and map which are impleme...

Calculate Hash or Checksum for a table in SQL Server

I'm trying to compute a checksum or a hash for an entire table in SQL Server 2008. The problem I'm running into is that the table contains an XML column datatype, which cannot be used by checksum and has to be converted to nvarchar first. So I need to break it down into two problems: calculate a checksum for a row, schema is unknown be...

Is it safe to store (hashed) passwords in a cookie?

I've read some articles and questions on SO (e.g. here) that say you shouldn't store a user's password in a cookie. If the password is salted and hashed, why is this insecure? In particular, why is it less secure than using sessions, the alternative usually suggested? If the user wants to stay logged in then surely this new cookie (with...

How can I take queries from one file, search another, and output to a third, in Perl?

Edit: My original title has been sort of changed. I suspect the current title does not reveal my original purpose: let perl automatically use the contents of one file as the source of search keywords to search another file and then output the matches to a third file. This means without this kind of automation, I would have to manually ty...

What's the most efficient way to partition a large hash into N smaller hashes in Ruby?

The Problem I'm working on a problem that involves sharding. As part of the problem I need to find the fastest way to partition a large Ruby hash (> 200,0000 entries) in two or more pieces. Are there any non O(n) approaches? Is there a non-Ruby i.e. C/C++ implementation? Please don't reply with examples using the trivial approach ...

max length of url hash parameter

Is there a limit of the length of an url hash parameter ...