Re: I have a question about the md5 hash.

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Tue, 11 Sep 2012 15:57:06 -0600

On 09/11/2012 10:41 AM, Eliezer Croitoru wrote:
> I have seen some of the code but I dont understand on what the
> calculation being done in literal works.
> to explain myself.
>
> I do know that it uses the url and the method to hash for the key.
> so there is a public and private keys.
> private is method+url+id
> public is url+method.
> the method\function uses this api:
> SquidMD5Update(&M, (unsigned char *) url, strlen(url));
> the internals of the function is a bit high for me so to translate it
> for me:
> let say in ruby i'm using:
> digest = Digest::MD5.hexdigest("Hello World\n")
> => "e59ff97941044f85df5297e1c302d260"
>
> is there any way to translate a url + method hash into ruby?
> a specific example is:
> 2012/09/11 18:37:45.949| storeKeypublicwith URL and method: GET
> http://laptope:3128/squid-internal-static/icons/silk/page_world.png
> 2012/09/11 18:37:45.949| storeGet: looking up
> E3F08214F440DC108204575CF98E2054
>
> I can try to do some thinks in the code that will show me each time the
> two options but I prefer to understand and plan what i'm suppose to see
> which will help me.

I do not know Ruby, but googling suggests that Ruby equivalent of
incremental MD5 hash creation would be something like this:

  incr_digest = Digest::MD5.new()
  incr_digest << url
  incr_digest << method
  return incr_digest.hexdigest

HTH,

Alex.
Received on Tue Sep 11 2012 - 21:57:31 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 12 2012 - 12:00:05 MDT