Instantly share code, notes, and snippets.

@bobber205 /twitter.rb Secret
Created Mar 15, 2018

Embed
What would you like to do?
def do_crc_check(params)
puts "Doing CRC Check!"
token = params['crc_token']
key = token
message = 'gDBU9XHrT1rrWuX8AGTc5WPuRMtrpkjF3NHBzaKr1gzssDlA2A'
# message = Chirpify::Environment.twitter_consumer_secret
# binding.pry
encoded = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), message, key)).strip()#.chomp('=')
response = {
'response_token' => "sha256=#{encoded}"
}
puts "Returning #{response}"
return ok(response)
end
def ok(body = 'OK')
if body.is_a?(Hash)
body = body.to_json
content_type = 'application/json'
else
content_type = 'text/html'
end
['200', { 'Content-Type' => content_type }, [body]]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment