Sha256: e620de6f2415b1464a6168a65b9456e7bcf1742a552ef810a6c5dc5aa3718788
Contents?: true
Size: 1013 Bytes
Versions: 3
Compression:
Stored size: 1013 Bytes
Contents
module Gtk2PasswordApp class Accounts def reset(password) @yzb = YamlZlibBlowfish.new(password) end attr_reader :data def initialize(dumpfile, password=nil) reset(password) if password # sets @yzb @dumpfile = dumpfile @data = {} end def exist? File.exist? @dumpfile end # will raise an exception on failed decryption def load(password=nil) reset(password) if password data = @yzb.load(@dumpfile) raise "Decryption error." unless data.class == Hash @data = data end def save(password=nil) reset(password) if password @yzb.dump(@dumpfile, @data) File.chmod(0600, @dumpfile) end def names @data.keys end def delete(account) @data.delete(account) end def get(account) raise "Account #{account} does NOT exists!" unless @data.has_key?(account) Account.new(account, @data) end def add(account) raise "Account #{account} exists!" if @data.has_key?(account) Account.new(account, @data) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gtk2passwordapp-5.2.1 | lib/gtk2passwordapp/accounts.rb |
gtk2passwordapp-5.1.0 | lib/gtk2passwordapp/accounts.rb |
gtk2passwordapp-5.0.0 | lib/gtk2passwordapp/accounts.rb |