If you only use the first 4 bytes of an MD5 hash, would that mean theoretically only 1 in 255^4 chance of collision? That is, are hashes designed such that you only have to use a small portion of the returned hash (say the hash is of a file of some size)?
...
this one creates an error:
@settings = {
:tab1 => {
:name => {
:required => true
},
:description
}
}
need to change :descrpition to :description => {}, but i don't have any values for :description so i want it to remain as is (without the empty => {})
Would you show me the best way to handle th...
Hi,
A bloom filter uses a hash function (or many) to generate a value between 0 and m given an input string X. My question is how to you use a hash function to generate a value in this way, for example an MD5 hash is typically represented by a 32 length hex string, how would I use an MD5 hashing algorithm to generate a value between 0 a...
How do I identify an item in a hash array if the key of the array is only known within a variable? For example:
var key = "myKey";
var array = {myKey: 1, anotherKey: 2};
alert(array.key);
Also, how would I assign a value to that key, having identified it with the variable?
This is, of course, assuming that I must use the variable key...
For this application I've mine I feel like I can get away with a 40 bit hash key, which seems awfully low, but see if you can confirm my reasoning (I want a small key because I want a small filename and the key will be converted to a filename):
(Note: only accidental collisions a concern - no security issues.)
A key point here is that...
I want to add elements to my Hash lists, which can have more than one value. Here is my code. I don't know how I can solve it!
class dictionary
def initialize(publisher)
@publisher=publisher
@list=Hash.new()
end
def []=(key,value)
@list << key unless @list.has_key?(key)
@list[key]...
Please help interpret the Birthday effect as described in Wikipedia:
A birthday attack works as follows:
Pick any message m and compute h(m).
Update list L. Check if h(m) is in the list L.
if (h(m),m) is already in L, a colliding message pair has been found.
else save the pair (h(m),m) in the
list L and go back to ...
In Perl, how do I get this:
$VAR1 = { '999' => { '998' => [ '908', '906', '0', '998', '907' ] } };
$VAR1 = { '999' => { '991' => [ '913', '920', '918', '998', '916', '919', '917', '915', '912', '914' ] } };
$VAR1 = { '999' => { '996' => [] } };
$VAR1 = { '999' => { '995' => [] } };
$VAR1 = { '999' => { '994' => [] } };
$VAR1 = { '9...
Hi, I'm working on a hash function which gets a string as input.
Right now I'm doing a loop and inside the hash (an int variable) is being multiplied by a value and then the ASCII code for the current character is added to the mix.
hash = hash * seed + string[i]
But sometimes, if the string is big enough there is an integer overflow ...
Theoretically does hashing a unique value yield a unique value?
Let's say I have a DB table with 2 columns: id and code. id is an auto-incrementing int and code is a varchar. If I do ...
$code = sha1($id);
... and then store $code into the same row as $id. Will my code column be unique as well?
What about if I append the current ...
Hi,
After reading the topic "Is MD5 really that bad", I was thinking about a better solution for generating hashes. Are there better solutions like Adler, CRC32 or SHA1? Or are they even broken?
...
I got many, many files to be uploaded to the server, and I just want a way to avoid duplicates.
Thus, generating a unique and small key value from a big string seemed something that a checksum was intended to do, and hashing seemed like the evolution of that.
So I was going to use hash md5 to do this. But then I read somewhere that "MD...
I want to compare the keys in a hash of parameters against an array of elements for a match.
For example:
params = {"key1", "key2", "key3"}
params_to_match = ["key2","key3"]
I could do this, but I'm sure there is a much more elegant way to acheive the same result
params.each_key{|key|
if params_to_match.include?(key.to_s)...
I need to store a password has in a SQL server 2000 database. The information isn't critical but I really don't want to store the password in clear text. How can I get a unique hash (sha, sha1, md5, etc) in SQL server 2000 as HashBytes isn't available.
I'm not looking for compiled DLL or the ilk, I dont have access to the server, needs ...
Hey,
I'm got a custom webview setup which is working pretty well, but I'd like to be able to either:
1, change the url hash without the webview reloading the page (it would lose the state of my js app)
2, call some js that sits within my web page from within android. I can't change any JS within the site, unfortunately, so can't cust...
I use MD5 hash for identifying files with unknown origin. No attacker here, so I don't care that MD5 has been broken and one can intendedly generate collisions.
My problem is I need to provide logging so that different problems are diagnosed easier. If I log every hash as a hex string that's too long, inconvenient and looks ugly, so I'd...
I'm trying to write a data structure which is a combination of Stack and HashSet with fast push/pop/membership (I'm looking for constant time operations). Think of Python's OrderedDict.
I tried a few things and I came up with the following code: HashInt and SetInt. I need to add some documentation to the source, but basically I use a ha...
I have a javascript hash table, like so:
var things = [ ];
things["hello"] = {"name" : "zzz I fell asleep", "number" : 7};
things["one"] = {"name" : "something", "number" : 18};
things["two"] = {"name" : "another thing", "number" : -2};
I want to sort these into order by name, so if I iterate through the hash table it will go in order...
Generally which is better to use?:
case n
when 'foo'
result = 'bar'
when 'peanut butter'
result = 'jelly'
when 'stack'
result = 'overflow'
return result
or
map = {'foo' => 'bar', 'peanut butter' => 'jelly', 'stack' => 'overflow'}
return map[n]
More specifically, when should I use case-statements and when should I simply use a ha...
Hi everyone,
Is it common sense to encrypt hashed&salted passwords that are stored in a database with a strong encryption (AES 192 or so) or are we just aiming for the stars?
Of course, the encryption key will not be in the database itself, but will be kept at a safe place.
Thanks a lot!
...