The sha1 hash of "abc" is
a9993e364706816aba3e25717850c26c9cd0d89d
The only way to get Mathematica to tell you that with its Hash function is
Hash[abc, "SHA"] // IntegerString[#, 16]&
(The IntegerString thing is just to output it in hex like most implementations do.)
Note that
Hash["abc", "SHA"]
gives the hash of "\"abc\"" ...
I need a ruby hash H with keys :a, :b, :c so that H[:b] = H[:a] + 1; H[:c] = H[:b] + 2 etc.
How can I define such a hash in a one line declaration, like H = {:a=>1, :b => H[:a] + 1, :c => H[:b] +2, ... } ?
I need something similar to DataMapper properties declaration:
property :path, FilePath
property :md5sum, String, :default => ...
digest = HMAC.digest(Digest.new(SHA1), Base64.decode64(key), HashString) return Base64.encode64(digest.to_s()).chomp()
What would the above be in PHP?
...
I'm aggregating RSS feeds using FeedTools.
I followed this tutorial: http://simonwoodside.com/weblog/2008/12/7/ruby%5Fon%5Frails%5Ffeedrss%5Faggregator/ and everything functioned fine.
The problem is I want to filter some of the hashes that exist within the array [:items] from inside the parsed feed hash.
Here's the RSS cached feed obj...
Example dump from the list of a directory:
hello:3.1 GB
world:1.2 MB
foo:956.2 KB
The above list is in the format of FILE:VALUE UNIT. How would one go about ordering each line above according to file size?
I thought perhaps to parse each line for the unit via the pattern ":VALUE UNIT" (or somehow use the delimiter) then run it throug...
I have a small code snippet that I'm trying to get to work in Ruby.
digest = HMAC.digest(Digest.new(SHA1), Base64.decode64(key), HashString) return Base64.encode64(digest.to_s()).chomp()
I tried it as follows:
hashstring = "POST application/octet-stream
Thu, 05 Jun 2008 16:38:19 GMT /rest/objects date:Thu, 05 Jun 2008 16:38:19 GMT g...
Ok, I’m trying to understand the reason to use salt.
When a user registers I generate a unique salt for him/her that I store in DB. Then I hash it and the password with SHA1. And when he/she is logging in I re-hash it with sha1($salt.$password).
But if someone hacks my database he can see the hashed password AND the salt.
Is that hard...
Hi,
Some hash functions are today not as safe as they were some years ago. Which hash function would currently be a good choice for hashing passwords?
Thanks in advance.
...
Hi
I want to be able to get a uniqe hash from all objects. What more,
in case of
Dictionary<string, MyObject> foo
I want the unique keys for:
string
MyObject
Properties in MyObject
foo[someKey]
foo
etc..
object.GetHashCode() does not guarantee unique return values for different objects.
That's what I need.
Any idea? Thank y...
Hi,
I'm using the unordered_map of TR1 implementation in my code and the linker gives weird errors I cannot even decipher:
BPCFG.o: In function `std::__detail::_Hash_code_base<DottedRule, std::pair<DottedRule const, int>, std::_Select1st<std::pair<DottedRule const, int> >, eqDottedRule, std::hash<DottedRule>, std::__detail::_Mod_rang...
I have a question about email hash on facebook if the email address has been changed by the facebook user.
My site stored the email hash to match with the facebook email hash to identify the user on our website is the same user on our facebook application. If a facebook user has two facebook account with different email address, and o...
I have no idea if this is a Hash issue or an Array issue, but I don't figure out why asterisk (*) sign is required in the third example to get a hash filled with data. Without it, it outputs an empty hash.
# -*- coding: utf-8 -*-
require 'pp'
pp [[:first_name, 'Shane'], [:last_name, 'Harvie']]
# => [[:first_name, "Shane"], [:last_name, ...
I am upgrading a cakephp app at my new job from l.1 to 1.2. I am replacing the homegrown 1.1 authorization code with the great Auth component. The problem is that the passwords are not hashed in the legacy DB. How can I turn off the password hashing temporarily so I can start using the Auth component.
Don't worry, I will hash the passwo...
Does anyone have any info on changing the hash of a file without corrupting it?
I read about appending a null byte to the end of the file, thus changing the MD5 without corrupting it. Anyone have any info?
The language I wish to do this in is PHP.
Thanks.
...
Here's a curiosity I've been investigating. The .NET Dictionary class performs ridiculously fast compared to the STL unordered_map in a test I keep running, and I can't figure out why.
(0.5 seconds vs. 4 seconds on my machine)
(.NET 3.5 SP1 vs. Visual Studio 2008 Express SP1's STL)
On the other hand, if I implement my own hash table i...
I have a ruby hash:
VALS = { :one => "One", :two => "Two" }
and an Array:
array2 = ["hello", "world", "One"]
Question: How can I populate a new array1 so that it only pulls in any values in array2 that match exactly the values in VALS?
For example, I have tried:
array2.each_with_index do |e,i|
array1 << e if VALS[i] ~= e
end
Alon...
I am trying to populate an array with an intersection of an array and hash based on hash values:
array2 = ["hi","world","One"]
Vals = {:one => "One", :two => "Two"}
array2 = VALS.values & array2
print array2
Works fine for intersection of hash values and array2[ i ], but if I want to instead populate with array2[ i+1 ] element from ar...
Many file storage systems use hashes to avoid duplication of the same file content data (among other reasons), e.g., Git and Dropbox both use SHA256. The file names and dates can be different, but as long as the content gets the same hash generated, it never gets stored more than once.
It seems this would be a sensible thing to do in a ...
I have a part of my application that stores files. Because we could potentially be adding many of the same file, I am first keeping a hash of each file. If two files have the same hash, then we throw out one, and both "references" to that file point to the same physical file.
How much should I be worried about hash collisions?
In th...
Hi,
im Using CakePHPs standard Auth mechanism, but I have some problems with that.
Everytime a user logges in the password got hashed twice.
I have the Auth Component in the var $componets Array in the app_controller.php
and one in the var $components Array from my users_controller where the login action is
defined. I have defined a ...