hash

How to hash and compare a pointer-to-member-function ?

How can i hash (std::tr1::hash or boost::hash) a c++ pointer-to-member-function? Example: I have several bool (Class::*functionPointer)() (not static) that point to several diferent methods of the class Class and i need to hash those pointer-to-member-function. How can i do that? Also how can i compare (std::less) those member funct...

two-way keyed encryption/hash algorithm

I am no way experienced in this type of thing so I am not even sure of the keywords (hence the title). Basically I need a two way function encrypt(w,x,y) = z decrypt(z) = w, x, y Where w = integer x = string (username) y = unix timestamp and z = is an 8 digit number (possibly including letters, spec isn't there yet.) ...

Renaming large IDs in R

Suppose I have a data.frame with N rows. The id column has 10 unique values; all those values are integers greater than 1e7. I would like to rename them to be numbered 1 through 10 and save these new IDs as a column in my data.frame. Additionally, I would like to easily determine 1) id given id.new and 2) id.new given id. For example...

Python: Set with only existance check?

I have a set of lots of big long strings that I want to do existence lookups for. I don't need the whole string ever to be saved. As far as i can tell, the set() actually stored the string which is eating up a lot of my memory. Does such a data structure exist? done = hash_only_set() while len(queue) > 0 : item = queue.pop() if i...

Calculate hash without having the entire buffer in memory at once

I am doing an operation where I receive some bytes from a component, do some processing, and then send it on to the next component. I need to be able to calculate the hash of all the data I have seen at any given time - and because of data size; I cannot keep it all in a local buffer. How would you calculate the (MD5) hash under these ...

Why does C# generate different EXEs for the same source-code?

Every time we recompile our C# application we end up with EXEs with different MD5 signatures. We are recompiling on the same machine, minutes apart. Why doesn't the same source-code yield the same output? Is there a way to fix this? ...

Is it a good idea to hash a Python class?

For example, suppose I do this: >>> class foo(object): ... pass ... >>> class bar(foo): ... pass ... >>> some_dict = { foo : 'foo', ... bar : 'bar'} >>> >>> some_dict[bar] 'bar' >>> some_dict[foo] 'foo' >>> hash(bar) 165007700 >>> id(bar) 165007700 Based on that, it looks like the class is getting hashed as its id number. T...

Converting integer identifiers to pointers

I have ID values of the type unsigned int. I need to map an Id to a pointer in constant time. Key Distribution: ID will have a value in the range of 0 to uint_max. Most of keys will be clustered into a single group, but there will be outliers. Implementation: I thought about using the C++ ext hash_map stuff, but I've heard thei...

MD5 file processing

Good morning all, I'm working on an MD5 file integrity check tool in C#. How long should it take for a file to be given an MD5 checksum value? For example, if I try to get a 2gb .mpg file, it is taking around 5 mins+ each time. This seems overly long. Am I just being impatient? Below is the code I'm running public string getHash(Str...

MD5 file hash for the same unchanged file is different each time C#

Good evening all, I've been working on an MD5 tool in C# that takes a file, goes through my Hasher class and pops the result in a database, along with the filename and directory. The issue I'm having is that each time I run the test, the MD5 result for the same identical file i.e. unchanged in any way is completely different. Below is...

Generating ids for a set of integers

Background: I'm working with permutations of the sequence of integers {0, 1, 2 ... , n}. I have a local search algorithm that transforms a permutation in some systematic way into another permutation. The point of the algorithm is to produce a permutation that minimises a cost function. I'd like to work with a wide range of problems, fro...

How do you assign new variable names when its already assigned to something? Ruby

The title really really doesn't explain things. My situation is that I would like to read a file and put the contents into a hash. Now, I want to make it clever, I want to create a loop that opens every file in a directory and put it into a hash. Problem is I don't know how to assign a name relative to the file name. eg: hash={} Dir.g...

how to create unique integer number from 3 different integers numbers(1 Oracle Long, 1 Date Field, 1 Short)

the thing is that, the 1st number is already ORACLE LONG, second one a Date (SQL DATE, no timestamp info extra), the last one being a Short value in the range 1000-100'000. how can I create sort of hash value that will be unique for each combination optimally? string concatenation and converting to long later: I don't want this, for ...

Best algorithm for hashing number values?

When dealing with a series of numbers, and wanting to use hash results for security reasons, what would be the best way to generate a hash value from a given series of digits? Examples of input would be credit card numbers, or bank account numbers. Preferred output would be a single unsigned integer to assist in matching purposes. My ...

Is it better to check Perl hash keys for truth or for existence?

Is it more preferrable, when assigning to a hash of just keys (where the values aren't really needed), to say: $hash{$new_key} = ""; Or to say: $hash{$new_key} = 1; One necessitates that you check for a key with exists, the other allows you to say either: if (exists $hash{$some_key}) or if ($hash{$some_key}) I would think tha...

How do I refresh an array in a foreach loop?

I am writing a Perl script to do some mathematical operations on a hash. This hash contains the values as given in the sample below. I have written the code below. If I execute this code for an array value separately without using a foreach loop, the output is fine. But if I run this using a foreach loop on the array values, the sum for...

Is a hash result ever the same as the source value?

This is more of a cryptography theory question, but is it possible that the result of a hash algorithm will ever be the same value as the source? For example, say I have a string: baf34551fecb48acc3da868eb85e1b6dac9de356 If I get the SHA1 hash on it, the result is: 4d2f72adbafddfe49a726990a1bcb8d34d3da162 In theory, is there ever a...

sql server 2005 - trigger to hash password at insertion

How could i create a trigger that at any insertion on my table [users] will change automatically the content of its [password] field to its MD5 hash? Ps: I do not want this being done at client side. ...

Hashtables (Dictionary etc) with integer keys

I've been puzzling over this for a few days... feel free to shoot down any of my assumptions. We're using a Dictionary with integer keys. I assume that the value of the key in this case is used directly as the hash. Does this mean (if the keys are grouped over a small range) that the distribution of the key hash (same as the key itself,...

good way to handle a bunch of data in a hash.

I'm returning a complex result of indeterminate size that I will need to handle again and again, so I'm wondering what is a good way to package it? something like this loop>>> @results = { external_id => { :name => name, :type => type } } or @results = [ { :external_id => external_id, :name => name, :type => type } ] or? end>>>...