Skip to content

Instantly share code, notes, and snippets.

View alexpapworth's full-sized avatar
👋
hi!

Alex Papworth alexpapworth

👋
hi!
View GitHub Profile
@chaintng
chaintng / javascript.js
Created June 9, 2018 05:34
Encryption Decryption Javascript and Ruby
// IDEA FROM: https://stackoverflow.com/questions/33929712/crypto-in-nodejs-and-ruby
var crypto = require('crypto'),
algorithm = 'aes-256-cbc',
key = 'SOME_RANDOM_KEY_32_CHR_123456789', // 32 Characters
iv = "0000000000000000"; // 16 Characters
function encrypt(text){
var cipher = crypto.createCipheriv(algorithm,key,iv)
var crypted = cipher.update(text,'utf-8',"base64")
@beccasaurus
beccasaurus / define_function.rb
Created August 12, 2011 22:25
Capybara helper for defining a JavaScript function in a page (globally, attached to window)
# Given the name and body for a JavaScript function, this defines the
# function globally in the page.
#
# This is most useful for making helper JavaScript functions that you can
# call later, eg. foo = evaluate_script('myFunction()')
#
# Usage:
#
# page.define_function :whatever, %{
# var foo = 'hello';