hash

Retrieving password when the password stored as a hash value

Can users request that their password be emailed to themselves if the password is stored as a hash value? Is there any way to convert a hash value to the clear text value with the proper information (& what information would you need)? If a user has the same password hash value stored on two sites, would their password be the same for ...

Calculating bittorent info_hash with java

I am trying to calculate the info_hash value for a torrent. I read the whole torrent into StringBuffer, then cut it like the following: d8:announce...info[d6:length...e]e I can't seem to get the correct hash. Does reading the torrent into a StringBuffer corrupt the byte string at the end? Am I missing something? public void calculate...

CSV into hash

I have a csv with the first column a label followed by comma separated values: LabelA,45,56,78,90 LabelB,56,65,43,32 LabelC,56,87,98,45 I'd like the first column (LabelA etc) to be the Key in a hash with the numeric values in an array. I can read the file into an array or scalar but I'm not sure what to do after that. Suggestions?? ...

migrate from C#.net 2.0 to php so the hash value of the password - how to resolve?

Hi we previously use a C#.net 2.0 to create a web app. Users password were hashed and stored in database using the following code. private const string encryptionKey = "AE09F72B007CAAB5"; HMACSHA1 hash = new HMACSHA1(); hash.Key = HexToByte(encryptionKey); encodedPassword = Convert.ToBase64String( hash.ComputeHash(Encoding.Unicod...

Is my authentication encryption any good?

So I've been reading a lot about encryption in PHP. So much that I am not sure exactly what's a really good method to securely store login information. However, the following function is what I came up with: function loginHash($username, $password){ $salt = str_split($password,(strlen($password)/2)+1); $hash = hash('whirlpool',...

Compare three-dimensional structures

I need to evaluate if two sets of 3d points are the same (ignoring translations and rotations) by finding and comparing a proper geometric hash. I did some paper research on geometric hashing techniques, and I found a couple of algorithms, that however tend to be complicated by "vision requirements" (eg. 2d to 3d, occlusions, shadows, et...

Initialize Java Generic Array of Type Generic

So I have this general purpose HashTable class I'm developing, and I want to use it generically for any number of incoming types, and I want to also initialize the internal storage array to be an array of LinkedList's (for collision purposes), where each LinkedList is specified ahead of time (for type safety) to be of the type of the gen...

MD4 implementation in C -- consistent, yet erroneous output

I can't seem to get my md4 implementation working. Any ideas as to what's wrong? Also, I'm not in the class that this project was assigned to.. I'm just doing it for kicks. I would also rather you give me hints than an outright answer. Thanks! EDIT: To be specific (as I know to be), my outputs do not match the test vectors provided ...

Flatten an array of hashes in ruby

I have some simple code that looks like this: fruit.each do |c| c.each do |key, value| puts value end end This works fine, but it feels un-ruby like. My goal is to take this array: [{"fruit_id"=>"1"}, {"fruit_id"=>"2"}, {"fruit_id"=>"3"}] And convert it to this: [ "1", "2", "3" ] Thoughts? ...

Converting hash to string in Ruby.

Let's say we have a hash: flash = {} flash[:error] = "This is an error." flash[:info] = "This is an information." I would like to convert it to a string: "<div class='error'>This is an error.</div><div class='info'>This is an information". in nice one liner ;) I found something like that: flash.to_a.collect{|item| "<div class='#{...

Help me better understand cryptographic hash functions

I was reading this question on MD5 hash values and the accepted answer confuses me. One of the main properties, as I understand it, of a cryptopgraphic hash function is that it is infeasible to find two different messages (inputs) with the same hash value. Yet the consensus answer to the question "why aren't MD5 hash values reversibl...

How to hash a GUID and a 64-bit timestamp into another GUID

We're working with a proprietary database and have a table whose semantic compound key consists of a 128-bit GUID and a 64-bit timestamp. "Semantic compound key" in a sense that multiple records with the same GUID may occur in the table, as well as multiple records with the same timestamp; however the pair (GUID, timestamp) is unique. As...

Prevent query string manipulation by adding a hash?

To protect a web application from query string manipulation, I was considering adding a query string parameter to every url which stores a SHA1 hash of all the other query string parameters & values, then validating against the hash on every request. Does this method provide strong protection against user manipulation of query string va...

SHA-1 Hashes Mixed with Strings

I have to parse something like the following "some text <40 byte hash>" can i read this whole thing in to a string without corrupting 40 byte hash part? The thing is hash is not going to be there so i don't want to process it while reading. EDIT: I forgot to mention that the 40 byte hash is 2x20 byte hashes no encoding raw bytes. ...

Strange behavior: Hash's keys cancel dynamic method definition

Let's say I want some instance of String behave differently from other, "normal" instances - for example cancel the effect of the "upcase" method. I do the following: class String def foo def self.upcase self end self end end It seems to work fine, and the way I need it: puts "bar".upcase #=> "BAR" puts "bar".fo...

Ran into issues while implementing hash table

I am trying to read a file which contains URLs and are 100 million in number. What I need to do is find out the different websites they are from. So, I am taking chunk of data in memory and reading it line by line. Also, I need to find out how many URLs does each website has in the file and what are those URLs. The way I figured it out i...

How can I retrieve a Perl hash value only if its key exists?

Code: %a = ( 1 => "ONE" , 2 => "TWO" , 3 => " Three", ); $test_value = 1 ; foreach $key (sort(keys %a)) { if ($key == $test_value ) { print $a{$key}; } } I just want to achieve the same operation in very short way. Is there any shortcut for this? ...

GetHashCode() based on a primary key - is it safe?

Hi, a class has an ID property and this property gets value from a primary key column of an SQL table. Is it a good practice if I write public override int GetHashCode() { return this.ID + GetType().GetHashCode(); } into my class? (Equals overrided already on the same way.) ...

Quickly determining if a set of files are identical in C#?

I have the need to relatively quickly be able to determine if a set of files on a user's machine has been processed before by my application. The app in question uploads the files for the user to a server, and if the files have been uploaded before, it skips the upload. My plan so far has been to hash the files and then store the results...

Ruby call method from hash

Hey, I asked a little earlier about a clever way to execute a method on a given condition see here The solutions (and response time!) was great, though upon implementation having a hash of lambdas gets ugly quite quickly. So I started experimenting. The following code works: def a() puts "hello world" end some_hash = { 0 => a() } s...