hash

Mysql binary storage problem

I'm hashing using sha256 and outputting it in binary, and storing it in Mysql's BINARY(32). echo $testsha256 = hash( 'sha256', "aKyAmNsb", true ); However, when I retrieve this value from the database, it's Different print_r(str_split($returnedpassword)); echo "<br>"; print_r(str_split($testsha256)); echo "<br>"; Array ( [0] ...

Improving set comparisons by hashing them (being overly clever..?)

After my last, failed, attempt at asking a question here I'm trying a more precise question this time: What I have: A huge dataset (finite, but I wasted days of multi-core processing time to compute it before...) of ISet<Point>. A list of input values between 0 to 2n, n17 What I need: 3) A table of [1], [2] where I map every value ...

Is perl's each function worth using?

From perldoc -f each we read: There is a single iterator for each hash, shared by all each, keys, and values function calls in the program; it can be reset by reading all the elements from the hash, or by evaluating keys HASH or values HASH. The iterator is not reset when you leave the scope containing the each(), and this can le...

Why this code does not do what I mean?

$w = 'self-powering'; %h = (self => 'self', power => 'pauә', ); if ($w =~ /(\w+)-(\w+)ing$/ && $1~~%h && $2~~%h && $h{$2}=~/ә$/) { $p = $h{$1}.$h{$2}.'riŋ'; print "$w:"," [","$p","] "; } I expect the output to be self-powering: selfpauәriŋ But what I get is: self-powering: [riŋ] My guess is something's wro...

Perl array and hash manipulation using map

I have the following test code use Data::Dumper; my $hash = { foo => 'bar', os => 'linux' }; my @keys = qw (foo os); my $extra = 'test'; my @final_array = (map {$hash->{$_}} @keys,$extra); print Dumper \@final_array; The output is $VAR1 = [ 'bar', 'linux', undef ...

How XOR Hash Works + Picking A Key

I've been tasked with implementing an XOR hash for a variable length binary string in Perl; the length can range from 18 up to well over 100. In my understanding of it, I XOR the binary string I have with a key. I've read two different applications of this online: One of the options is if the length of my key is shorter than the string...

How to break up data into good sized parts

I'm writing a multi-length-output hash function, but I've hit as stumbling block: how can i break up input data in such a way that the program will not have to deal with extremely long lists or run too many loops for the given data? a = input length in bytes, a>=0 b = output length in nibbles, b>0 minimal padding is done to the data be...

Converting a md5 hash byte array to a string

How can I convert the hashed result, which a byte array, to a string? byte[] bytePassword = Encoding.UTF8.GetBytes(password); using (MD5 md5 = MD5.Create()) { byte[] byteHashedPassword = md5.ComputeHash(bytePassword); } So I need to convert byteHashedPassword to a string ...

Is the result of a md5 hash consistant or server dependent?

I am doing a md5 hash, and just want to make sure the result of: md5.ComputeHash(bytePassword); Is consistent regardless of the server? e.g. windows 2003/2008 and 32/64 bit etc. ...

computing hash values, integral types versus struct/class

hello I would like to know if there is a difference in speed between computing hash value (for example std::map key) of primitive integral type, such as int64_t and pod type, for example struct { int16_t v[4]; };. what about int128_t versus struct {int32_t v[4];}? I know this is going to implementation specific, so my question ultimat...

Are hash collisions with different file sizes just as likely as same file size?

I'm hashing a large number of files, and to avoid hash collisions, I'm also storing a file's original size - that way, even if there's a hash collision, it's extremely unlikely that the file sizes will also be identical. Is this sound (a hash collision is equally likely to be of any size), or do I need another piece of information (if a ...

How are hash functions like MD5 unique?

Im aware that MD5 has had some collisions but this is more of a high level question about hashing functions. If MD5 hashes any arbitrary string into a 32-digit hex value, then according to the Pigeonhole Principle surely this can not be unique as there are more unique arbitrary strings than there are unique 32-digit hex values ...

A 16-digit hashing function

Is there a hash function that returns a 16-digit hex value (as MD5 returns 32-digit), or is there a library (for C++) in which I can use MD5 or SHA-1 which returns a 16-digit value ...

how does hash element make a secure login on zend framework?

hello all i saw a example for login form same blow code class Form_Login extends Zend_Form { //put your code here public function init($timeout=360){ $this->addElement('hash', 'token', array( 'timeout' => $timeout )); $this->setName('Login'); $username = $this->createElement ( 'text'...

Ruby: How can I make these objects the same?

So I have the following hashes/arrays: {"number"=>[{"tracking"=>"1Z81E74W0393736553", "notes"=>"Example note"}, {"tracking"=>"9102901001301227214058"}]} {"number"=>{"tracking"=>"1Z81E74W0393736553", "notes"=>"Example note"}} That first hash has an array for number while the second one doesn't. It's wreaking havoc trying to loop thro...

How can I store an inventory using Perl hashes?

For an assignment in college, we have to make a script in Perl that allows us to manage an inventory for an e-store. (The example given was Amazon). Users can make orders in a fully text-based environment and the inventory must be updated when an order is completed. Every item in the inventory has 3 to 4 attributes: a product code, a ti...

Print Current Mercurial Revision Hash?

Is there a better way extract the current revision hash in Mercurial than hg log -l1|grep changeset|cut -d: -f3 ? Part of my webapp deployment script "tags" the uploaded app tarball with its unique revision hash. ...

How can I convert one Perl hash to another using the keys?

I've just started diving in to the crazy world that is perl and have come across a problem that I cannot seem to wrap my head around. Specifically I need to be able to convert from one hash structure to another, that uses the keys/values as the new hashes keys/values. An example: Input hash: my %original_hash = ( first_key => ...

Comparing large strings in JavaScript with a hash

I have a form with a textarea that can contain large amounts of content (say, articles for a blog) edited using one of a number of third party rich text editors. I'm trying to implement something like an autosave feature, which should submit the content through ajax if it's changed. However, I have to work around the fact that some of th...

Why am I getting "ARRAY(0x145030c)" trying to write a Perl hash to a file?

I have a hash in which I store the products a customer buys (%orders). It uses the product code as key and has a reference to an array with the other info as value. At the end of the program, I have to rewrite the inventory to the updated version (i.e. subtract the quantity of the bought items) This is how I do rewrite the inventory: ...