hash

C# Reading back encrypted passwords

Hi all, I'm using the code below to save a password to the registry, how do I convert it back? The code below isn't mine but it encrypts well. Thanks using System.Security.Cryptography; public static string EncodePasswordToBase64(string password) { byte[] bytes = Encoding.Unicode.GetBytes(password); byte[] dst = new byte[by...

Using Python to authenticate against raw username, hash, salt in DB created by ASP.NET roles/membership

Hello all. We have a current application where user login credentials are stored in a SQL Server DB. These are, basically, stored as a plain text username, a password hash, and an associated salt for this hash. These were all created by built in functions in ASP.NET's membership/role system. Here's a row for a user named 'joe' and a ...

Why does this map statement in Perl not compile?

This fails: my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-$_" => 1 } @a; with this error: Not enough arguments for map at foo.pl line 4, near "} @a" but this works: my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-" . $_ => 1 } @a; why? ...

How can I convert these strings to a hash in Perl?

I wish to convert a single string with multiple delimiters into a key=>value hash structure. Is there a simple way to accomplish this? My current implementation is: sub readConfigFile() { my %CONFIG; my $index = 0; open(CON_FILE, "config"); my @lines = <CON_FILE>; close(CON_FILE); my @array = split(/>/, $lines[0]); my $total = @...

Hash Functions and Tables of size of the form 2^p

While calculating the hash table bucket index from the hash code of a key, why do we avoid use of remainder after division (modulo) when the size of the array of buckets is a power of 2? ...

What issues do you consider when designing a hash function?

I am not looking for links to information on hashing. I am not looking for the worlds greatest hash function. I am interested in mini-stories describing The problem domain you were working in The nature of the data you were working with What your thought process was in designing a hash function for your data. How happy were you with ...

Ways to hash a numeric vector?

Are there any known hash algorithms which input a vector of int's and output a single int that work similarly to an inner product? In other words, I am thinking about a hash algorithm that might look like this in C++: // For simplicity, I'm not worrying about overflow, and assuming |v| < 7. int HashVector(const vector<int>& v) { cons...

Chosing a suitable table size for a Hash.

If I have a key set of 1000, what is a suitable size for my Hash table, and how is that determined? ...

Faster MD5 alternative?

Hello everyone, I'm working on a program that searches entire drives for a given file. At the moment, I calculate an MD5 hash for the known file and then scan all files recursively, looking for a match. The only problem is that MD5 is painfully slow on large files. Is there a faster alternative that I can use while retaining a very sma...

What is this Base64 Look-alike?

I am new to decoding techniques and have just learnt about base64, sha-1, md5 and a few others yesterday. I have been trying to figure out what "orkut" worms actually contain. I was attacked by many orkut spammers and hackers in the past few days, and there is a similarity in the URLs that they send to us. I don't know what informa...

Hash Collision - what are the chances?

I have some code on my PHP powered site that creates a random hash (using sha1()) and I use it to match records in the database. This is to obfuscate things like id's in query strings which can (and usually are) sequential, and I don't want anyone changing it in the query string to get other information. What are the chances of a collis...

Why does Java's hashCode() in String use 31 as a multiplier?

In Java, the hash code for a String object is computed as s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation. Why is 31 used as a multiplier? I understand that the multiplier should be a relatively large prime ...

Fastest way to calculate file hash?

A lot of files will be stored in the DB and I need file hashes to unique identify that the file was not changed. (In general, will be used as the Windows Personal Firewall part) ...

Creating unmodifiable files

I want to be able to create a file, distribute it to an end-user, but prevent them from making modifications to the file. Now, obviously, I can't actually stop anybody from modifying the file - so my approach is to detect and reject the file if it's modified. My intention is to generate a salted hash of the file contents and append it ...

How can I make hash key lookup case-insensitive?

Evidently hash keys are compared in a case-sensitive manner. $ perl -e '%hash = ( FOO => 1 ); printf "%s\n", ( exists $hash{foo} ) ? "Yes" : "No";' No $ perl -e '%hash = ( FOO => 1 ); printf "%s\n", ( exists $hash{FOO} ) ? "Yes" : "No";' Yes Is there a setting to change that for the current script? Thanks. ...

How can I change the case of a hash key?

I am writing a script which is likely to be modified by users. Currently I am storing the configuration settings inside the script. It exists in the form of a hash-of-hashes. I would like to guard against people accidentally using lowercase characters in the hash keys, because that will break my script. It would be simple to inspect th...

Probabilistic file verification -- algorithm or libraries?

I am looking for an efficient means to partially check the integrity of "large" data sets over a slow transfer medium. This seems like a common problem as file sizes grow out of proportion to transfer rates. For example, for concrete numbers, a terabyte of data over USB2. Checking that this data is still valid by reading every byte in...

SQL Server Hash Indexes

When using the CHECKSUM column type to artificially create a hash index, is the lookup actually O(1) or is it still O(lg n) like it is for a clustered index? I have a table from which I will select based on its ID column and I need the lookup to be as fast as possible, so is the clustered index the fastest possible option? I am looking f...

Visual basic 6.0 hash function

In my application I need to hash a string before I save it to a text file. Does anyone know how to do that? ...

Difference between Hashing a Password and Encrypting it

The current top-voted to this question states: Another one that's not so much a security issue, although it is security-related, is complete and abject failure to grok the difference between hashing a password and encrypting it. Most commonly found in code where the programmer is trying to provide unsafe "Remind me of my password" fu...