curl \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "User-Token: 18773930-285a-434a-b044-533252e49435" \
-X POST \
-d '{"following": {"username": "sentul"}}' \
http://localhost:3000/followings
Showing posts with label Ruby on Rails. Show all posts
Showing posts with label Ruby on Rails. Show all posts
Tuesday, August 26, 2014
Simulate mobile accessing Rails API
You might be using Rails API to create a back end while the view layer is handled by mobile application. So how do you simulate sending headers to the API (i.e: authentication). You can use terminal and do a curl command:
Thursday, February 13, 2014
Bundle Install not responding
There are times where bundle install command does not giving any output for a long period of time (giving broken pipe via ssh). You can try using this command and see the output:
bundle --verbose
Friday, February 22, 2013
RSA Encryption and Decryption
1. Generate private key (choose your own pass phrase)
e is 65537 (0x10001)
Enter pass phrase for private.pem:
Verifying - Enter pass phrase for private.pem:
2. Extract public key
writing RSA key
3. To encrypt data
4. To decrypt data. The pass phrase is 'sentul asia' as an example. Your cyphertext will definitely differ from the one below.
openssl genrsa -des3 -out private.pem 2048Generating RSA private key, 2048 bit long modulus ......................................................................+++ ..............+++
e is 65537 (0x10001)
Enter pass phrase for private.pem:
Verifying - Enter pass phrase for private.pem:
2. Extract public key
openssl rsa -in private.pem -out public.pem -outform PEM -puboutEnter pass phrase for private.pem:
writing RSA key
3. To encrypt data
require 'openssl'ZXRd/2jJpYEJkQroWcs1QVJIII+yeQWtBPeSilSWqel5l8WcdGg2vwFh4rcf dKXjk54WPn/2jfBkk6TBssHcYr6wbHlzJG9MjqZHAqhWgaVRA9R9fDYkFS6F o0Nqtpp46B4luilKhC6npWS4zlR9vyIJwyp3mLDnbPaB5sUIGluOoRtE1Z7k 3jYAF6Xz9fYCJqVPGHoO7xDALNMEmJqxCHjFttxjAZoiEL84AdT3ZI3FJUmv nxgyuGu9daYpfK+8kVXlW/qqVPKdQmWSOEVlTXzSq9j4pgWvuTk6Jg21b7Hf NHJ515iSBdt5NGPgNCPeB4mNhq3hOkmMwX7HRppf1Q==
require 'base64'
plaintext = 'Sentul was here.';
publickey = OpenSSL::PKey::RSA.new(File.read('public.pem'))
cyphertext = Base64.encode64(publickey.public_encrypt(plaintext))
print cyphertext, "\n"
4. To decrypt data. The pass phrase is 'sentul asia' as an example. Your cyphertext will definitely differ from the one below.
require 'openssl'Sentul was here.
require 'base64'
passphrase = 'sentul asia'
cyphertext = %Q{ ZXRd/2jJpYEJkQroWcs1QVJIII+yeQWtBPeSilSWqel5l8WcdGg2vwFh4rcf dKXjk54WPn/2jfBkk6TBssHcYr6wbHlzJG9MjqZHAqhWgaVRA9R9fDYkFS6F o0Nqtpp46B4luilKhC6npWS4zlR9vyIJwyp3mLDnbPaB5sUIGluOoRtE1Z7k 3jYAF6Xz9fYCJqVPGHoO7xDALNMEmJqxCHjFttxjAZoiEL84AdT3ZI3FJUmv nxgyuGu9daYpfK+8kVXlW/qqVPKdQmWSOEVlTXzSq9j4pgWvuTk6Jg21b7Hf NHJ515iSBdt5NGPgNCPeB4mNhq3hOkmMwX7HRppf1Q== }
privatekey = OpenSSL::PKey::RSA.new(File.read('private.pem'),passphrase)
plaintext = privatekey.private_decrypt(Base64.decode64(cyphertext))
print plaintext"
Subscribe to:
Posts (Atom)



