hash

smallest value of hash() function?

in python (3), what is the smallest value that hash(x) can return? i want to use hashes to give a quick 'fingerprint' to database values (basically making it easy to see whether two longish, similar texts are actually equal or not), and want to get rid of negative numbers (for simplicity), so i thought i'd just add the smallest possibl...

Is it safe to ignore the possibility of SHA collisions in practice?

Let's say we have a billion unique images, one megabyte each. We calculate the SHA-256 hash for the contents of each file. The possibility of collision depends on: the number of files the size of the single file How far we can go ignoring this possibility, assuming it is zero? ...

A hash function returning a value between -1 and 1

I'm searching for a hash function that takes as input any integer (positive or negative, though it could be constrained to the int range if this makes it easier), and returns a real number between -1 and 1. Is there such a function, or any obvious way to build it from another hash function? The function doesn't have to be secure, as lo...

why does a collision detection in a cryptographic hash function make finding other collisions easier?

Hi, For wikipedia I read: Joux[3] noted that 2-collisions lead to n-collisions: if it is feasible to find two messages with the same MD5 hash, it is effectively no more difficult to find as many messages as the attacker desires with identical MD5 hashes. But why is this so? I can't imagine why? The algorithms are open right, people ...

Cryptographically secure additive hash function

I am working on a Fountain Code based file transfer system. In this system blocks of data are downloaded, combined with an xor function. I want to verify the blocks as they arrive. What I need is a cryptographically secure hash function which has the property: Hash(A) ^ Hash(B) == Hash(A ^ B) does such a thing exist? Note: The data b...

split a 256 bit hash into 32 bit prefix in python

In python, how does one split a SHA256 hash into a 32bit prefixes? I'm working with Google's safebrowsing api, which requires that I compare 32bit prefixes between my own collection, and the collection the API sends to me. I understand how to pull the list from Google, and I understand how to form a collection of hashes from parsed URLs,...

How can I get a hash of an entire table in postgresql?

I would like a fairly efficient way to condense an entire table to a hash value. I have some tools that generate entire data tables, which can then be used to generate further tables, and so on. I'm trying to implement a simplistic build system to coordinate build runs and avoid repeating work. I want to be able to record hashes of the ...

Using a random salt in password encryption?

Hey, I've seen a few other threads about this topic, but I can't seem to find a few answers to some questions involving the use of a random salt in password encryption. To my understanding, the steps go something like this: Generate a random salt for the user. Append the salt to their password. Use something like SHA-2 to hash the res...

Suitable hash function for data corruption

What is the most suitable hash function for file integrity checking (checksums) to detect corruption? I need to consider the following: Wide range of file size (1 kb to 10GB+) Lots of different file types Large collection of files (+/-100 TB and growing) Do larger files require higher digest sizes (SHA-1 vs SHA 512)? I see that the S...

Secure a PHP file; how?

I have a classifieds website, and a partner of us (who runs another classifieds website) need to have access to a file on our server. The file is called 'partner.php'. This file simply prints out some information about the classifieds on our site. So for our partners, they would just need to access "www.domain.com/partner.php?id=1234"...

Memory-efficient string-to-string map in Python (or C)

I need a memory-efficient data structure for for storing about a million key--value pairs, where keys are strings of about 80 bytes, and values are strings of about 200 bytes, the total key and value size being about 280MB. I also need efficient lookup of value by key, preferably a hash-map. The memory overhead should be as little as pos...

Array to Hash Ruby

Okay so here's the deal, I've been googling for ages to find a solution to this and while there are many out there, they don't seem to do the job I'm looking for. Basically I have an array structured like this ["item 1", "item 2", "item 3", "item 4"] I want to convert this to a Hash so it looks like this { "item 1" => "item 2", "...

Javascript: Change specific part of the hash

So for example I have: http://www.example.com/index.php#/parameter1=one/parameter2=two/ Now how should I update only the parameter1's value? ...

Javascript hash replace error

What's the problem with this? the hash is : #/search=hello/somethingelse/ window.location.hash.replace(/search=([^\/]*)/gi, "search=" + value); EDIT: I want to change just a specific part of the hash not the whole hash. ...

How can I create a time-series bar graph in Ruby on Rails with a hash?

I am able to create a time-series "hash" using the statistics gem: => #<OrderedHash {"2010-10-23"=>2, "2010-09-22"=>3, "2010-09-11"=>1, "2010-08-27"=>1, "2010-10-15"=> 1, "2010-09-15"=>1, "2010-08-08"=>2, "2010-10-17"=>14, "2010-10-06"=>2, "2010-09-28"=>1, "2010-10-19 "=>1, "2010-09-20"=>1}> I want to create a simple graph with this d...

Does onHashChange work in Safari?

Does onHashChange or hashChange work in Safari? I tested it with Safari 4.0.4 on Windows 7 and it doesn't work for me. If it doesn't work, is there any solution to track if the hash has changed? ...

Is MD5 still good enough to uniquely identify files?

Is MD5 hashing a file still considered a good enough method to uniquely identify it given all the breaking of MD5 algorithm and security issues etc? Security is not my primary concern here, but uniquely identifying each file is. Any thoughts? Thanks a lot in advance :) ...

Salting a secret with itself before storing in a DB, what are the weaknesses?

I've heard of people using this approach and would like to know what the implications are. I just know it's a bad idea! From what I understand, salting a password before storing the hash in a DB has the primary purpose of making every hashing algorithm unique, and thus requiring a new rainbow table for every user when trying to crack it...

track tab history plus links on tabs for back button functionality?

Hi all, I've got a page with fg.menu and jquery UI tabs that works fairly well. I've got custom handlers to load menu links into the selected tab. The tabs are all ajax-loaded and the contents also have their own links, which I've handled as such in my tab options: var tabOpts = { select:handleSelect, event: 'change', load: func...

Why doesn't my Perl variable have the right value outside the if() block?

I have a hash, where the keys and values are from matches in a regular expression. I'm having difficulty extracting the values given the keys. In the interest of brevity and honing in on the problem, my first version of this post I attempted to strip down my program to only the relevant parts, but it wasn't enough, so here's more. Variab...