{{toc}}
- Use UTF-8. It’s 21 century, 8bit encodings dead now.
- Use 2 space indent, not tabs
- Use Unix-style line endings
- Keep lines not longer than 80 chars
| require 'rubygems' | |
| require 'openssl' | |
| require 'digest/md5' | |
| key = OpenSSL::PKey::RSA.new(2048) | |
| cipher = OpenSSL::Cipher::AES.new(256, :CBC) | |
| ctx = OpenSSL::SSL::SSLContext.new | |
| puts "Spoof must be in DER format and saved as root.cer" | |
| raw = File.read "root.cer" | |
| cert = OpenSSL::X509::Certificate.new raw | |
| cert.version = 2 |
| #! /usr/bin/env python | |
| import redis | |
| import random | |
| import pylibmc | |
| import sys | |
| r = redis.Redis(host = 'localhost', port = 6389) | |
| mc = pylibmc.Client(['localhost:11222']) |
#Simple Authentication with Bcrypt
This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.
The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).
You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault
##Steps
| #!/usr/bin/env ruby | |
| # Author : Emad Elsaid (https://github.com/blazeeboy) | |
| require 'koala' # gem install koala --no-document | |
| # create a facebook app and get access token from here | |
| # https://developers.facebook.com/tools/explorer | |
| # select "user_status", "friends_status", "user_checkins" when authenticating | |
| oauth_access_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
| graph = Koala::Facebook::API.new(oauth_access_token) | |
| places = [] |
| task :env_checker do | |
| unless Rails.env.development? | |
| puts "Not in development environment, exiting!" | |
| exit 1 | |
| end | |
| end | |
| namespace :app_name do | |
| desc 'Anonymize user, company, and location information' | |
| task :anonymize => [:environment, :env_checker] do |
| require "sinatra/base" | |
| require "sinatra/namespace" | |
| require "multi_json" | |
| require "api/authentication" | |
| require "api/error_handling" | |
| require "api/pagination" | |
| module Api | |
| class Base < ::Sinatra::Base |
| backend default { | |
| .host = "127.0.0.1"; | |
| .port = "8080"; | |
| .connect_timeout = 600s; | |
| .first_byte_timeout = 600s; | |
| .between_bytes_timeout = 600s; | |
| } | |
| acl purge { | |
| "localhost"; |
| # The initial was for Varnish 2.1, this has been updated for Varnish 3. | |
| # The upgrade changes were based on the docs here: | |
| # https://www.varnish-cache.org/docs/3.0/installation/upgrade.html | |
| # https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html | |
| # https://www.varnish-cache.org/trac/wiki/VCLExamples | |
| # Summary | |
| # 1. Varnish will poll the backend at /health_check to make sure it is | |
| # healthy. If the backend goes down, varnish will server stale content | |
| # from the cache for up to 1 hour. |
| #!/usr/bin/python | |
| ''' | |
| Python implementation of passcode hashing algorithm used on the Samsung Galaxy S4 GT-I9505 4.2.2 | |
| Correct PIN for hash and salt below is 1234. | |
| Get 40-character hash value in ascii hex format from file /data/system/password.key on the phone | |
| Get salt in signed numeric format by doing sqlite3 query SELECT value FROM locksettings WHERE name = 'lockscreen.password_salt' on /data/system/locksettings.db |