سؤال

I'm getting from Slideshare API explorer which is working:

64f43b4be73bc11a15142c1ef5dab1130c5064cb

From SHA1 hashing of below string

81LqkNkvy1391428643

But when I use in Rails:

Digest::SHA1.hexdigest("81LqkNkvy1391428643")

I get:

1ef520bb53227b9edf691d47da653f93d232e16e

I cannot figure out why this is not matching.

According to Slideshare API link

http://www.slideshare.net/developers/documentation

It clearly says

hash: Set this to the SHA1 hash of the concatenation of the shared secret and the 
timestamp (ts). i.e. SHA1 (sharedsecret + timestamp). The order of the terms 
in the concatenation is important.

I thought I followed the instructions correctly. I also tried decryption of above SHA1 strings but had no luck so far.

What could be the issue here?

هل كانت مفيدة؟

المحلول

URL parameter from the API explorer with shared secret set to 81LqkNkvy:

...&hash=80c887e839d79dc38248ed4cda4b6ad401f57305&ts=1391434954

In Ruby:

sharedsecret = '81LqkNkvy'
timestamp = 1391434954

require 'digest'
Digest::SHA1.hexdigest(sharedsecret + timestamp.to_s)
#=> "80c887e839d79dc38248ed4cda4b6ad401f57305"

And to get the current timestamp:

timestamp = Time.now.to_i
#=> 1391434369

Note that the hash changes every second.

نصائح أخرى

Tried time stamp in milliseconds ?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top