hash

Given filename, how can I get the Adler32 using Crypto++

Given a "string filename", how can I get the Adler32 checksum using the C++ Crypto++ library. I am a little confused about using their FileSource and Sink system. Below I have the skeleton of the code that does MD5, but I can't seem to find any examples or tutorials on the Adler32 usage. string filename = "/tmp/data.txt" string file_ad...

authentication method

I am writing a server-client application to receive user message and publish it. Thinking about authentication method. Asymmetric encryption, probably RSA. Hash (salt+password+'msg'+'userid'), SHA256 HMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data. Symmetric Encryption of the '...

C# How to select a Hashcode for a class that violates the Equals contract?

I've got multiple classes that, for certain reasons, do not follow the official Equals contract. In the overwritten GetHashCode() these classes simply return 0 so they can be used in a Hashmap. Some of these classes implement the same interface and there are Hashmaps using this interface as key. So I figured that every class should at l...

Need to store string as id for objects in some fast data structure

I'm implementing a session store for a web-server. Keys are string and stored objects are pointers. I tried using map but need something faster. I will look up an object 5-20 times as frequent than insert. I tried using hash-map but failed. I felt like I got more constraints than more free time. I'm coding c/c++ under Linux. I don't...

The correct way to encrypt a string using HmacSHA256 in VB.NET

Hello, I need to create a keyed hash for a string of XML to send to a 3rd party. This is the code I am using but it is producing a different hash then the example the 3rd party has sent me. I have been through all the tutorials I can find and re-read MSDN again and again, what am I doing wrong? Or should I suspect a problem at the other...

Better way to fill a Ruby hash?

Is there a better way to do this? (it looks clunky) form_params = {} form_params['tid'] = tid form_params['qid'] = qid form_params['pri'] = pri form_params['sec'] = sec form_params['to_u'] = to_u form_params['to_d'] = to_d form_params['from'] = from form_params['wl'] = wl ...

Gravatar for Iphone? How do I generate a hexadecimal MD5 hash?

I'd like to use gravatar in my iPhone application. Is there anyway to generate a hexadecimal MD5 hash in Objective-C for iPhone? Using openssl on iPhone is a no-go. ...

How can I efficiently handle multiple Perl search/replace operations on the same string?

So my Perl script basically takes a string and then tries to clean it up by doing multiple search and replaces on it, like so: $text =~ s/<[^>]+>/ /g; $text =~ s/\s+/ /g; $text =~ s/[\(\{\[]\d+[\(\{\[]/ /g; $text =~ s/\s+[<>]+\s+/\. /g; $text =~ s/\s+/ /g; $text =~ s/\.*\s*[\*|\#]+\s*([A-Z\"])/\. $1/g; # replace . **** Begin or . #### B...

Password hash and salting - is this a good method?

I was doing a little research or googling for different methods of handling password hashing and salting and came across this interesting link: http://phix.me/salt/ Now, essentially what this proposes is the creation of two user functions, one for hashing and one for checking the hash. The salt is pseudo random but is in actual fact ...

Are the first 32 bits of an md5 hash just as "random" as any other substring?

I'm looking to create a 32-bit hash of some data objects. Since I don't feel like writing my own hash function and md5 is available, my current approach is to use the first 32 bits (i.e. first 8 hex digits) from an md5 hash. Is this acceptable? In other words, are the first 32 bits of an md5 hash just as "random" as any other substrin...

Bloom filter or cuckoo hashing?

Which do you prefer and why? They both can be used to accomplish similar tasks but I'm curious as to see what people have used in actual applications and their reasoning for doing so. ...

How does one encode and decode a string with Python for use in a URL?

Hi, I have a string like this: String A: [ 12234_1_Hello'World_34433_22acb_4554344_accCC44 ] I would like to encrypt String A to be used in a clean URL. something like this: String B: [ cYdfkeYss4543423sdfHsaaZ ] Is there a encode API in python, given String A, it returns String B? Is there a decode API in python, given String B,...

Salting a C# MD5 ComputeHash on a stream

I can't see any way to salt a MD5.ComputeHash(Stream). Am I missing some way of injecting bytes into the HashAlgorithm? I tried performing a ComputeHash(byte[]) before performing the stream compute, but, unsurprisingly, it had no effect. Any ideas (apart from modifying the file)? Thanks for your time. addendum Just to be a little mor...

How to uniquely identify a user defined type in D?

I need to generate something that can be used as a unique handle for a user defined type (struct or class) in the D programming language. Preferably this would be a compile time computable value. I want the handle to relate to the name of the type as well as change if the internal structure (data layout) of the type changes but remain th...

What is a difference of Array and Hash? :php

What is differents from an arrangement in a hash in PHP? An arrangement: array(1,2,3...) A hash: array(key1=value1, key2=value2, ...) Or will it be a thing to treat as the totally same thing? ※ For example, will the function arguments allows array be effective for the hash? Because I distinguish it by the conventional language...

Performance of Oracle's dbms_crypto.hash function for SHA-1

Looking for stats for input sizes of at least between 4 and 30 MB. ...

Ideas to create a small (<10 digits), not (very) secure "hash"

I'm working on an online event ticketing system, where users will be able to self print his tickets and show up at the event where it will be scanned (barcode) and ideally the person will get in. My problem is how to create a "ticket code" that fulfills the following requirements: each "ticket code" need to be sufficiently different fr...

I am missing something about the usefulness of hashes

So, hashes are useful because they change password/login name/salt value combinations to a code that cannot be reversed. The client sends this hash to the server. The server compares the hash to a list of stored hashes to see if the client's user may be granted access. But how do I prevent a malicious user from intercepting the hashed pa...

Why we use Hash Code in HashTable instead of an Index?

How that integer hash is generated by the GetHashCode() function? Is it a random value which is not unique? In string, it is overridden to make sure that there exists only one hash code for a particular string. How to do that? How searching for specific key in a hash table is speeded up using hash code? What are the advantages...

Fast algorithm for finding next smallest and largest number in a set

I have a set of positive numbers. Given a number not in the set, I want to find the next smallest and next largest numbers that are in the set. The only way I can think to do it now is to find the next smallest by decreasing by 1 until I find a number in the set, and then do the same for finding the next largest. Motivation: I have a bu...