hash

Hashset vs Treeset

I've always loved trees, that nice O(n*lg(n)) and the tidyness of them. However, every software engineer I've ever known has asked me pointedly why I would use a treeset. From a CS background, I don't think it matters all that much which you use, and I don't care to mess around with hash functions and buckets (in the case of Java). In w...

Why does Digest::SHA come up with different hashes than those shown in RFC 4868?

I'm trying to write some Perl to inter operate with hash functions in other languages, namely Java at this point. We have found what is presumably a correct source, RFC 4868 which includes some test keys & strings along with their hashed values. I'm using the following snippet, and can't get Perl to come up with the same result. I can ...

Ruby: Create hash with default keys + values of an array

I believe this has been asked/answered before in a slightly different context, and I've seen answers to some examples somewhat similar to this - but nothing seems to exactly fit. I have an array of email addresses: @emails = ["[email protected]", "[email protected]"] I want to create a hash out of this array, but it must look like this: i...

Should I use $hash{"string"} or $hash{string} in Perl?

In Perl, which of these is the "better" style? $hash{"string"} or $hash{string}? In any case, are they functionality identical? ...

Is there a standard for using PBKDF2 as a password hash?

Join me in the fight against weak password hashes. A PBKDF2 password hash should contain the salt, the number of iterations, and the hash itself so it's possible to verify later. Is there a standard format, like RFC2307's {SSHA}, for PBKDF2 password hashes? BCRYPT is great but PBKDF2 is easier to implement. Apparently, there's no spec....

Calculate hash/checksum in Informix SQL

I would like to calculate some sort of hash or checksum value for a column value in Informix SQL. The problem: We need to anonymize personal information in test data, and would like to do so by hashing the relevant values, as in: UPDATE personal_data SET name=HASH(name), employee_no=HASH(employee_no) We want to use a hash, rather th...

Crypto, hashes and password questions, total noob?

I've read several stackoverflow posts about this topic, particularly this one: http://stackoverflow.com/questions/401656/secure-hash-and-salt-for-php-passwords but I still have a few questions, I need some clarification, please let me know if the following statements are true and explain your comments: If someone has access to your d...

fastest code to generate unique base62 hashes

hey guys i want to generate unique base62 hashes - something similar to what tinyurl and bit.ly do using c#. this would be based on an auto increment field ID of type bigint (like most of these sites) min chars would be 1 and max chars would be 6... if you had to write the fastest code (least amount of cpu usage) in c# for this hash how...

initialize all hashes with a default_proc

I wanted to extend the Hash class so that all hashes get same default_proc when they're created. So I put this in my file: class Hash def initialize self.default_proc = proc { |hash, key| raise NameError, "#{key} is not allowed" } end end This works fine if I use this syntax h = Hash.new but not if I use h = {} Playing wit...

Ruby initialize method: setting instance variable with a hash key

Hello, I am facing a undefined local variable or method error when initializing the following in ruby: class Model attr_accessor :var1, :var2, :state def initialize (x, y, key) @var1 = x @var2 = y @state = every_state[:key] #this line produces the error @every_state = { :A => SateA.new, :B => StateB.new, :C =>...

How can I get the vbulletin logout hash on another page? (PHP)

I want to get the logout hash for vBulletin so that I can link to the logout bit directly from my main site. How can I do this? (in PHP) ...

Why multiply by a prime before xoring in many GetHashCode Implementations?

I understand that multiplication by a large number before xoring should help with badly distributed operands but why should the multiplier be a prime? Related: Why should hash functions use a prime number modulus? Close, but not quite a Duplicate: Why does Javas hashCode() in String use 31 as a multiplier? ...

How to replace a Perl hash key?

Let us say if I have a hash like this: $data = { 'key1' => { 'key2' => 'value1' }, 'key3' => { 'key4' => { 'key5' => 'value2' } }, }; Now, how can I replace the the key 'key5' with some other key name say 'key6'?...

What kind of hash is this?

Hello, What kind of hash is this? Y16T+T/2sBhrDvaA9MBGGeh9D0pJVpkihCw= ...

Cumulative Hashes

I've read before here on SO that there are some hash algorithms (I think one of those is adler32) that support the following property: adler32('abc'); // 123 adler32('def'); // 456 adler32('abcdef'); // 579 (123 + 456) Please note that the results are only examples to demonstrate what I want to archieve. I've tried some examples with ...

How do I sort by value from a second level hash, in Perl?

my $hash_ref = { one => { val => 1, name => 'one' }, three => { val => 3, name => 'three'}, two => { val => 2, name => 'two' }, }; I would like to sort $hash_ref such that a foreach would order them by $hash_ref->{$key}->{'val'} one two three Any suggestions? ...

Implementing a database record hash for keeping track of whether a record has changed or not

I have database schema for an integration project in which I need to be able to query for records that have changed, but only based on a given set of fields within that record. So, for instance, here's an example table: CUSTOMERS ID Name Phone Fax Balance I need to be to query to fetch records whose Name, Phone, or Fax fields have...

I have a simple database of content. Should I hash the "id" so that people don't look over it in the URL?

Is it recommended to create a column (unique key) that is a hash. When people view my URL, it is currently like this: url.com/?id=2134 But, people can look over this and data-mine all the content, right? Is it RECOMMENDED to go 1 extra step to make this through hash? url.com?id=3fjsdFNHDNSL Thanks! ...

What is the best reversable hash algorithm for a URL? (near-Zero collision!)

Suppose I have one URL. http://google.com ...I'd like to turn it into a hash. S3jvZLSDK. Then take this hash and reverse it! into http://google.com. To you geeks out there--what is the BEST method to do this for near-ZERO collision? ...

Unhashing a hash C#

Can someone reverse this handy hash code I'm using? using System.Security.Cryptography; public static string EncodePasswordToBase64(string password) { byte[] bytes = Encoding.Unicode.GetBytes(password); byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes); return Convert.ToBase64String(inArray); } Everything I en...