22
голосов
7ответов
24686 просмотров

How can I maintain the order of keys I add to a Perl hash?

How can I maintain the order of actual list after counting its occurrence using a hash in the following program? For example, <DATA> are a b e a c d a c d b etc. Using hash, i counted the occurrence of each element. and what i want is: a 3 b 2 e 1 c 2 d 2 but the following p...

3
голосов
1ответов
3252 просмотров

Hashing-algorithm for dates

What would be a good hash-algorithm to hash dates, e.g. 24/12/09 and 31/10/89? The dates would range from about year 1950 to 2050. Could using the unix timestamp somehow, be possible?

1
голосов
1ответов
976 просмотров

Python way to do crc32b

As i posted as title, there is a way to use the crc32b hash on python natively or through a library (i.e. chilkat)? My intention is to "translate" a program from php to python, so output should be same as in php: $hashedData= hash('crc32b',$data); -> Edit: in a win32 system Thanks to all ;)

4
голосов
4ответов
943 просмотров

Caching data vs. writing in memory table

Which would be the best way to achieve a fast hash / session storage with one of these three ways? Way 1: Create a memory table in MySQL that stores a hash and a timestamp when the entry was created. A MySQL event automatically deletes all entries older than 20 minutes. This should be pretty fas...

3
голосов
3ответов
1353 просмотров

Pure Python persistent key and value based container (a hash like interface) with large file system support?

I am looking for a (possibly) pure Python library for persistent hash table (btree or b+tree which would provide following features Large file support (possibly in terabytes) Fast enough and low memory footprint (looking for a descent balance between speed and memory) Low cost of management Rel...

93
голосов
4ответов
65225 просмотров

Java Equivalent to Python Dictionaries

I am a long time user of Python and really like the way that the dictionaries are used. They are very intuitive and easy to use. Is there a good Java equivalent to python's dictionaries? I have heard of people using hashmaps and hashtables. Could someone explain the similarities and differences o...

12
голосов
7ответов
6416 просмотров

Good hash function for permutations?

I have got numbers in a specific range (usually from 0 to about 1000). An algorithm selects some numbers from this range (about 3 to 10 numbers). This selection is done quite often, and I need to check if a permutation of the chosen numbers has already been selected. e.g one step selects [1, 10,...

1
голосов
6ответов
527 просмотров

Encoding patterns in a 2D space (matrix)

I have a 2D MxN grid (or matrix). The cells in the matrix may hold an integer. A cell with a non-zero integer is said to be populated. The set of populated cells in the matrix is known as a "configuration". I want to come up with an encoding or hashing algorithm that wil allow me to uniquely ide...

2
голосов
1ответов
3965 просмотров

How do a use a SecureString to create a SHA1 or SHA512 Hash?

I would like to use a SecureString varible within VB.NET and convert that to a SHA1 or SHA512 hash. How would I securely convert the SecureString to the Byte array that HashAlgorithm.ComputeHash will accept?

1
голосов
3ответов
593 просмотров

Populating an array of hashes with arrays of hashes

I am currently developing a piece of monitoring software that takes an input file of server names and ip addresses and creates a rudimentary database of information. I want to default some values as it processes the config file and it works fine for the first time round the loop but any subsequen...

10
голосов
4ответов
9763 просмотров

Generating an XML document hash in C#

What's the best way to go about hashing an XML document in C#? I'd like to hash an XML document so that I can tell if it was manually changed from when it was generated. I'm not using this for security--it's OK if someone changes the XML, and changes the hash to match. For example, I'd hash the ...

2
голосов
2ответов
2477 просмотров

Hashed passwords and the entity framework

I've got a Users table and the HashedPassword column is of the binary(16) type. It's used to store an MD5 hash. To generate the hash I created a couple of stored procedures: CreateUser, EditUser and LoginUser. They have a parameter that accepts a password in plaintext, convert it to the MD5 hash ...

2
голосов
3ответов
1792 просмотров

How to Store Passwords in Databases and Cookies (PHP/MySQL)

Having read this article and many others out there on how to not store passwords in databases and cookies, I'm wondering now how I should do it... What I've come up so far (after reading around a bit) is taking the clear-text user password, padding it with salt till it fills up 512 bits (64 byte...

3
голосов
4ответов
251 просмотров

How can I use an existing array as a value in a hash in Perl?

I have an existing array I wish to add as a value in a hash. I know you can use arrays as values but can see no way of assigning an existing one. I basically want to go: $hash{fieldName} = @myArray; Only that obviously doesn't work! Help appreciated!

1
голосов
7ответов
736 просмотров

Is it a bad idea to send the hash of a password instead of the unhashed password?

For example, if the user has JavaScript enabled, we send hash his password and send the hash. If not, we send the password unhashed and a flag to mark that it is unhashed. We then build the hash (if it's unhashed) and compare it to the stored hash. This seems to be secure and simple. Why isn't i...

2
голосов
8ответов
957 просмотров

Efficient ways of telling whether or not a string/file has changed - crc32? md5? something else?

I'm looking for an efficient way to tell whether or not a string (or a file) has changed since the last time we looked at it. So, we run this function against 1,000,000 files/strings (each file/string is less than 1000 bytes), and store the output for each file/string. I'll then wait a few da...

2
голосов
4ответов
4364 просмотров

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.To...

-2
голосов
4ответов
1221 просмотров

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?

2
голосов
3ответов
400 просмотров

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 T...

6
голосов
2ответов
6623 просмотров

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 rec...

2
голосов
4ответов
2755 просмотров

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 thre...

0
голосов
5ответов
1191 просмотров

Cumulative Hashes

I've read before here on SO (EDIT: Incremental Checksums) that there are some checksum 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 exa...

1
голосов
3ответов
4759 просмотров

What kind of hash is this?

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

20
голосов
3ответов
17665 просмотров

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 replac...

4
голосов
4ответов
2261 просмотров

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 Java’s hashCode() in String use 31 as a...

2
голосов
1ответов
2845 просмотров

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)

1
голосов
3ответов
9207 просмотров

Ruby initialize method: setting instance variable with a hash key

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 => S...

2
голосов
2ответов
384 просмотров

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....

2
голосов
2ответов
4522 просмотров

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 am...

3
голосов
9ответов
813 просмотров

Crypto, hashes and password questions, total noob?

I've read several stackoverflow posts about this topic, particularly this one: 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...