# $Date: 2009/02/18 00:41:54 $ require 'yaml' require 'rubygems' require 'crypt/blowfish' class IOCrypt def initialize(passphrase) @blowfish = Crypt::Blowfish.new(passphrase[0..55]) end def load(dumpfile) data = nil File.open(dumpfile,'r'){|fh| data = YAML.load( @blowfish.decrypt_string( fh.read ) ) } return data end def dump(dumpfile, data) count = nil File.open(dumpfile,'w') do |fh| count = fh.write( @blowfish.encrypt_string( YAML.dump( data ) ) ) end return count end end