Skip to content

Instantly share code, notes, and snippets.

@ankane
Last active July 22, 2022 18:16
Show Gist options
  • Save ankane/35332faacd7ed70d8e51ea5bbb17dfb8 to your computer and use it in GitHub Desktop.
Save ankane/35332faacd7ed70d8e51ea5bbb17dfb8 to your computer and use it in GitHub Desktop.
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "activerecord", require: "active_record"
gem "sqlite3"
gem "lockbox", git: "https://github.com/ankane/lockbox.git"
end
puts "Lockbox version: #{Lockbox::VERSION}"
Lockbox.master_key = "0"*64
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Schema.define do
create_table :users do |t|
t.text :email_ciphertext
end
end
class User < ActiveRecord::Base
has_encrypted :email
end
user = User.create!(email: "[email protected]")
p user.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment