hash

Java: large persistent hash structure?

Hi All, I'm looking for a persistent hash structure in java, a simple key-value store, where key is a unique string and value is an int. The value of a key is to be incremented each time an existing key is added to the store. I need this to be quite large - possibly 500m - 1bn keys. I've been evaluating tokyo-cabinet http://fallabs.com...

Active menu class for current page

Hello, i'm making portfolio site template. I have problem about "active link" for my full ajax site. When i open url (http://bit.ly/d5qNeN) directly, url doesnt come up with addClass function. How can i add 'selected' class for directly opened urls? Here is my jquery code, which adds 'selected' class to my navi bar. $j("a[rel=...

How can I call a subroutine whose name is a value in a hash, in Perl?

$ cat test.pl use strict; use warnings; sub route { print "hello, world!"; } my %h; $h{'a'} = 'route'; print "1\n"; $h{a}; print "2\n"; $h{a}(); print "3\n"; "$h{a}".(); $ perl test.pl Useless use of hash element in void context at test.pl line 12. Useless use of concatenation (.) or string in void context at test.pl line 18. 1 ...

Can't seem to generate hex-encoded string from SHA256 digest in Java

Can't seem to figure out where Im going wrong here: private static String generateHashFromFile(String filePath) { try { final int BUFSZ = 32768; MessageDigest sha = MessageDigest.getInstance("SHA-256"); FileInputStream in = new FileInputStream(filePath); BufferedInputStream is = new BufferedInputStream(in, BUFSZ); byte...

How can I create a hash of hashes from an array of hashes in Perl?

I have an array of hashes, all with the same set of keys, e.g.: my $aoa= [ {NAME=>'Dave', AGE=>12, SEX=>'M', ID=>123456, NATIONALITY=>'Swedish'}, {NAME=>'Susan', AGE=>36, SEX=>'F', ID=>543210, NATIONALITY=>'Swedish'}, {NAME=>'Bart', AGE=>120, SEX=>'M', ID=>987654, NATIONALITY=>'British'}, ] I would like to write a subroutine that w...

Is this a good security strategy?

I'm trying to make a web service secure. It's not for a bank or anything of that sort, but the organization using it may lose some money if the service will be used by someone not authorized (it's hard to tell exactly how much..). The purpose is not to allow unauthorized applications to use any method (other than "GetChallenge". for u...

Ruby string to raw binary

Hey everyone, in PHP there is the hash() function that can return raw binary data. http://de2.php.net/manual/en/function.hash.php I want to do the same in Ruby. How do I do that? I generate the hash with: h = Digest::SHA2.new(512) << "hashme" PHP generates 32 byte of "raw binary output". ...

What's the big O for JavaScript's array when used as a hash?

What's the big O for JavaScript's array access when used as a hash? For example, var x= []; for(var i=0; i<100000; i++){ x[i.toString()+'a'] = 123; // using string to illustrate x[alpha] } alert(x['9999a']); // linear search? One can hope JS engines will not use a linear search internally O(n), but is this for sure? ...

Using XEnroll to create a PKCS10 with SHA-256 Hash Algorithm

I am trying to create a SHA-256 PKCS10 using Microsoft´s CSP (Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)) but without success. I have to do this using the XEnroll API (Windows XP / SP3). Here´s the sample for generating a SHA-1 PKCS10 (works just fine!): Set Enroll=CreateObject("CEnroll.CEnroll.2") Enroll.provid...

How can I build a Perl hash in C code?

I wish to embed a C code in Perl. In this C code I want to read a huge file into memory, make some changes and build a hash (a custom one). I wish to make this hash accessible from my Perl code. Is it possible? How can I reach the goal? ...

Can I safely use hashes of tuples containing 64 bit integers (longs) as unique keys in a python dictionary?

I have to store objects that have two attributes (ida and idb) inside a dict. Both attributes are 64 bit positive integers and I can only store one object for a unique arrangement(combination in which the order matters) of ida and idb. For example: obj1 = SomeClass(ida=5223372036854775807, idb=2) obj2 = SomeClass(ida=2, idb=522337203685...

2-way encryption in PHP - need some guidance

I'm working on my first secure shopping site. We're not storing credit card data, so that's not a problem. However, we do have a transaction key and API login key for our payment gateway (authorize.net) that I'd prefer to keep in a database, rather than hard-coding into my php. I don't know that we need tremendous security, but I would r...

How can I update window.location.hash without jumping the document?

I have a sliding panel set up on my website. When it finished animating, I set the hash like so function() { window.location.hash = id; } (this is a callback, and the id is assigned earlier). This works good, to allow the user to bookmark the panel, and also for the non JavaScript version to work. However, when I update the hash...

Rails not encoding nested data from POST

Hello, I am currently working on rails3 application that uses jQuery. I have a javascript plugin that returns an array of JSON data based on selections that the user has made. I have a save button that reads this array of data form the java script plug in and posts it back to the rails application to be saved. The javascript seems to be ...

Ideas on how to uniquely identify a computer?

I have been thinking of ways I could uniquely identify a computer in python. First, I thought about checking the user's mac address and hard disk space, then I tried to compute some sort of rating from many of these variables. However, this solution doesn't feel right. It takes a long time to run and I had to change it many times already...

php - Is strpos the fastest way to search for a string in a large body of text?

if (strpos(htmlentities($storage->getMessage($i)),'chocolate')) Hi, I'm using gmail oauth access to find specific text strings in email addresses. Is there a way to find text instances quicker and more efficiently than using strpos in the above code? Should I be using a hash technique? ...

Ideal hashing method for wide distribution of values?

As part of my rhythm game that I'm working, I'm allowing users to create and upload custom songs and notecharts. I'm thinking of hashing the song and notecharts to uniquely identify them. Of course, I'd like as few collisions as possible, however, cryptographic strength isn't of much importance here as a wide uniform range. In addition, ...

Improve the speed of locating a row (integer columns)

I have a 15 integer column with 5,000,000 rows in a table. Given a input record containing 15 integers I need to compare the input record with the 5,000,000 record table and obtain all matching rows. Note1: All integers within a row are unique Note2: the order of columns matching and the input record is not important. for example: 1, 1...

Target tabs within tabs with #hash URL (or otherwise)

I am using the jQuery Tools library Tabs. You can find them here: http://flowplayer.org/tools/tabs/index.html My basic markup is something like this: $("#tab-holder ul").tabs("div.tab", { history: true, api: true }) $("#profile-sub-tabs ul.menu").tabs("div"); The #profile-sub-tabs is another tab interface within the main #tab-holder ...

jQuery find attribute from url hash

Trying to find the attribute value from a url hash. // URL http://url.com/index.html#link // HTML <a href="#link" rel="3">Some link</a> // JS var anchor = window.location.hash.substring(1); // Need help finding attribute value from finding the anchor var attribute = .find('#+anchor').attr('rel'); //this needs to have a value of 3 Al...