Created
February 4, 2010 23:37
-
-
Save nolman/295276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'rubygems' | |
require 'mechanize' | |
agent = WWW::Mechanize.new() | |
page = agent.get(:url => "https://www.gmail.com") | |
#use OpenSSL between mechanize requests. | |
public_key = OpenSSL::PKey::RSA.new(File.read(File.dirname(__FILE__) + "/mykeypublic.pem")) | |
private_key = OpenSSL::PKey::RSA.new(File.read(File.dirname(__FILE__) + "/mykey.pem")) | |
data = "hello world" | |
puts "Data Before Encryption: #{data}" | |
encrypted_data = public_key.public_encrypt(data) | |
dencrypted_data = private_key.private_decrypt(encrypted_data) | |
puts "Data After Decryption: #{dencrypted_data}" | |
response = agent.submit(page.forms.first) | |
#will raise: OpenSSL::SSL::SSLError: SSL_read:: no start line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN RSA PRIVATE KEY----- | |
MIICXQIBAAKBgQDBLXT5EwIrLvdyTGc3hcjAFj7yBngLarwwm6jtWLHtEXm1ehKV | |
nd4rNUF6Et1kFbk4h4fOsj2vS0bpcGDGPg8X120w/nAsx+MWB069vHi4qHhQ27Mo | |
WSqti4xd0QNxl5TerlGo8IlibikXdaGykhElocWB/NL1HjL8z+ww1YkyewIDAQAB | |
AoGAM+5WbcbwZE+B8dYcQU7Twt+4GDQo/Vi6Mo8GAJhBbKuv/ltMt6/y08bDTV/Y | |
6Fj2q/2zQpuj/YXNEGBHg8OXJqdD1qq3AHS4fbvlD2d/si2OdMmKoDw0WOwUjhAs | |
WWZLVaRclILqhJp7gT6IM+eXsQcGPotC1weBQgNl17oKmfECQQD5nimefxbj9Krs | |
ahdWT1E9D9p9q3TntenCk+U02LKKk6lO827tfSwfOgos7NtyqC9tY7HGO9drFm/h | |
2AC3zhcfAkEAxh3fb8jvW/gls4pANjlOHj3LqXPP0us7GqPfNulsRnKxf02XRs2t | |
8E8aY9uLIXM9ihgXZCrM/eG816VNnWvFJQJAIfeJxk2Y+dATajRNlKsabOq5Wpx4 | |
PgedFaM2b2iFcyIAygOKNrrvxBgLxm08t293dLU6PbVq7OGSu/K+tkRPFQJBAMK7 | |
5j4Ygb4iwdwiTk9+MFzlXOSo42Rst2HOJb/x3O26GuIIwGNmFEybVFNHHxC4F4s/ | |
du6Ma4Y5dsd4wju0DMkCQQCJRS+G9VkQXunJSUL81UYAwkEhcR6MH95RkP/T1Khz | |
Kuu+3Mwz+Po5TDUq45V9UPZWe3FALP0tc1elOcwvSCyw | |
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN PUBLIC KEY----- | |
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBLXT5EwIrLvdyTGc3hcjAFj7y | |
BngLarwwm6jtWLHtEXm1ehKVnd4rNUF6Et1kFbk4h4fOsj2vS0bpcGDGPg8X120w | |
/nAsx+MWB069vHi4qHhQ27MoWSqti4xd0QNxl5TerlGo8IlibikXdaGykhElocWB | |
/NL1HjL8z+ww1YkyewIDAQAB | |
-----END PUBLIC KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'rubygems' | |
require 'mechanize' | |
agent = WWW::Mechanize.new() | |
page = agent.get(:url => "https://www.gmail.com") | |
response = agent.submit(page.forms.first) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment