class SecurePStore

Wrap PStore, combine with OpenSSL::Cipher to secure store on disk with a given passphrase

SecurePStore

Useable exactly like PStore except for initialization.

With PStore:

wiki = PStore.new("wiki_pages.pstore")
wiki.transaction do  # begin transaction; do all of this or none of it
  # store page...
  wiki[home_page.page_name] = home_page
  # ensure that an index has been created...
  wiki[:wiki_index] ||= Array.new
  # update wiki index...
  wiki[:wiki_index].push(*home_page.wiki_page_references)
end                  # commit changes to wiki data store file

With SecurePStore:

wiki = SecurePStore.new("wiki_pages.pstore", passphrase: 'do it this way instead')
wiki.transaction do  # begin transaction; do all of this or none of it
  # store page...
  wiki[home_page.page_name] = home_page
  # ensure that an index has been created...
  wiki[:wiki_index] ||= Array.new
  # update wiki index...
  wiki[:wiki_index].push(*home_page.wiki_page_references)
end                  # commit changes to wiki data store file

Simple!

Public Class Methods

initialize( file_name, secure_opts = {} ) click to toggle source

Creates a new SecureStore object, which will store data in file_name. If the file does not already exist, it will be created.

Options passed in through secure_opts will be used behind the scenes when writing the encrypted file to disk.

Calls superclass method
# File lib/diary-ruby/ext/secure_pstore.rb, line 48
def initialize file_name, secure_opts = {}
  @opt = secure_opts
  super
end

Public Instance Methods

empty_marshal_checksum() click to toggle source
# File lib/diary-ruby/ext/secure_pstore.rb, line 81
def empty_marshal_checksum
  @empty_marshal_checksum ||= begin
                                Digest::MD5.digest(empty_marshal_data)
                              end
end
empty_marshal_data() click to toggle source
# File lib/diary-ruby/ext/secure_pstore.rb, line 74
def empty_marshal_data
  @empty_marshal_data ||= begin
                            m = Marshal.dump({})
                            Encryptor.encrypt(m, @opt[:passphrase])
                          end
end
marshal_dump_supports_canonical_option?() click to toggle source
# File lib/diary-ruby/ext/secure_pstore.rb, line 70
def marshal_dump_supports_canonical_option?
  false
end