If I have this class:
class A
attr_accessor :b,:c,:d
end
and this code:
a = A.new
h = {"b"=>10,"c"=>20,"d"=>30}
is it possible to initialize the object directly from the hash, without me needing to go over each pair and call instance_variable_set? Something like:
a = A.new(h)
which should cause each instance variable to be ini...
I want a Python object that will monitor whether other objects have changed since the last time they were checked in, probably by storing their hash and comparing. It should behave sort of like this:
>>> library = Library()
>>> library.is_changed(object1)
False
>>> object1.change_somehow()
>>> library.is_changed(object1)
True
>>> librar...
I'm definitely a newbie to ruby (and using 1.9.1), so any help is appreciated. Everything I've learned about Ruby has been from using google. I'm trying to compare two arrays of hashes and due to the sizes, it's taking way to long and flirts with running out of memory. Any help would be appreciated.
I have a Class (ParseCSV) with mul...
Let's say I want to calculate a hash of a data structure, using a hash algorithm like MD5 which accepts a serial stream, for the purposes of equivalence checking. (I want to record the hash, then recalculate the hash on the same or an equivalent data structure later, and check the hashes to gauge equivalence with high probability.)
Are ...
Can anybody explain the logic behind the use of djb2 hash function as a good option for strings. The algorithm can be found at http://www.cse.yorku.ca/~oz/hash.html
Why is it that 5381 and 33 hold such an importance in djb2 algorithm ???
Thanks,
De Costo
...
I am looking for an implementation of the Rabin Hash Function in Java, Can anyone recommend a fast library?
Update:
I've just tested the library here.
It takes ~2200ms to hash 1mm random urls on my 2GHz processor.
This is certainly good enough for my needs, however I will test another library when I get a monent and post the results...
Hello everyone. In a WinForm application using C#.NET 2.0 (on Vista), I am using SHA1 hash to create a hash from a string and store the hash in a text file (with UTF-8 encoding). I want to use the hash stored in text file to in a condition. When I run the project in Vista it works properly (i.e. the condition results in true), but when I...
Hey i would like do have your input on this
I use this to generate unique salts to each of my users when they register (random letters and numbers). how big is the chance that salts will colide?
uniqid(mt_rand());
I then use md5 to hash salt, password and email(in that order) together as password and rehash when they log-in.
md5($sa...
I am trying to reload current page with different url hash, but it doesn't work as expected.
(Clarification how I want it to work: Reload the page and then scroll to the new hash.)
Approach #1:
window.location.hash = "#" + newhash;
Only scrolls to this anchor without reloading the page.
Approach #2:
window.location.hash = "#" + ne...
Hello
I'm trying to build a safe user authentication system.
The code is from http://net.tutsplus.com/tutorials/php/simple-techniques-to-lock-down-your-website/
But Im trying to change from md5 to sha-256, But It wont login.
I just changed from
$auth_pass = md5( $row['salt'] . $password . $stat_salt );
to
$auth_pass = hash('sha25...
I'm seeking the most concise way to do this
Given the following Array:
['a','b','c']
how to get this:
{'a'=> 1,'b'=> 2, 'c'=> 3}
and
[['a',1],['b',2],['c',3]]
I have few solutions at mind, just want to see yours :)
...
Database Data:
Passport_No Bank statement_no Credit_id
4126897 HSBC 2948608 0
4126897 HSBC 2948609 1
4126858 HSBC 2948591 0
4126858 barclays 2948595 0
4126858 barclays 2948596 1
4126858 barclays 2948597 2
The credit id is ba...
What does it mean to hash a password?
...
I am struggling through objects in perl, and am trying to create a 2d array and store it in a hash field of my object. I understand that to create a 2d array I need an array of references to arrays, but when I try to do it I get this error: Type of arg 1 to push must be array (not hash element) The constructor works fine, and set_seqs wo...
I am tasked with programming a routine that will run on a iSeries platform - where I pass in a parm (like userid, timestamp, etc...) into a program that can perform SHA-2 data encryption. I take the encryption result and format it into a string to open a browser.
I know how to open a browser using a CLP but trying to find a way to pe...
I've got a piece of code that works fine. It basically loops through each element of a hash using foreach() and applies a transformation to it using a regular expression, like so :
foreach my $key ( keys( %{$results} ) ) {
$results->{$key}{uri} =~ s/\".*\/(.*\.*(gif|jpe?g|png))\"/\/resources\/uploads\/$1/gi;
}
$results is a hashref...
My coworker and I are having a fist-fight civilized discussion over password security. Please help us resolve our differences.
One of us takes the viewpoint that:
Storing passwords encrypted using a public key in addition to a one-way hashed version is OK and might be useful for integration with other authentication systems in the fut...
I had a strange bug when porting a feature to the Python 3.1 fork of my program. I narrowed it down to the following hypothesis:
In contrast to Python 2.x, in Python 3.x if an object has a .__eq__ method it is automatically unhashable.
Is this true?
Here's what happens in Python 3.1:
>>> class O(object):
def __eq__(self, other):
...
Hello,
Does anybody have any experience of using the CMPH hashing library to create specific hash functions callable from c#. Any help would be appreciated
Does anybody know of any state of the art hashing algorithms that can be called from c# and don't explicity offer a copyleft licence.
Thanks
Bob.
...
Hi, i want to do the following:
I want to declare the instance variables of a class iterating over a dictionary.
Let's assume that i have this hash
hash = {"key1" => "value1","key2" => "value2","key3" => "value3"}
and i want to have each key as instance variable of a class. I want to know if i could declare the variables iterating o...