Sha256: d0994630eec881b66c250cc718c0871392822955be94f8b8d846dba2332559c5

Contents?: true

Size: 625 Bytes

Versions: 5

Compression:

Stored size: 625 Bytes

Contents

# frozen_string_literal: true

require "bundler/inline"

gemfile do
  gem "attr_keyring",
      require: "keyring",
      path: File.expand_path("..", __dir__)
end

gem "attr_keyring"
require "keyring"

keyring = Keyring.new("1" => "uDiMcWVNTuz//naQ88sOcN+E40CyBRGzGTT7OkoBS6M=")

# STEP 1: Encrypt message using latest encryption key.
encrypted, keyring_id, digest = keyring.encrypt("super secret")

puts "🔒 #{encrypted}"
puts "🔑 #{keyring_id}"
puts "🔎 #{digest}"

# STEP 2: Decrypted message using encryption key defined by keyring id.
decrypted = keyring.decrypt(encrypted, keyring_id)
puts "✉️ #{decrypted}"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attr_keyring-0.7.0 examples/keyring_sample.rb
attr_keyring-0.6.1 examples/keyring_sample.rb
attr_keyring-0.6.0 examples/keyring_sample.rb
attr_keyring-0.5.4 examples/keyring_sample.rb
attr_keyring-0.5.3 examples/keyring_sample.rb