Sha256: 542e3d7015a8e32df858f021df2928a08c4bebc3a84844dbff81bc894e21eecc
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
= BiCrypt require 'bicrypt' Encrypt string. e = BiCrypt.new("akey") m = e.encrypt_string("This is a message!") m.assert! == "This is a message!" Decrypt string. d = BiCrypt.new("akey") r = d.decrypt_string(m) r.assert == "This is a message!" Encrypt file. File.open('EXAMPLE.txt', 'w'){ |f| f << "This is an example." } e = BiCrypt.new("akey") e.encrypt_file('EXAMPLE.txt', 'secret.txt') File.read('EXAMPLE.txt').assert! == File.read('secret.txt') Decrypt file. d = BiCrypt.new("akey") d.decrypt_file('secret.txt', 'tmp/README.rdoc') File.read('EXAMPLE.txt').assert == File.read('EXAMPLE.txt') Both the string and the file methods are built on top of the general stream methods. plainIO = StringIO.new("This is the message!") cryptIO = StringIO.new('') e = BiCrypt.new("akey") e.encrypt_stream(plainIO, cryptIO) Decrypt IO stream. crypt2IO = StringIO.new(cryptIO.string) resultIO = StringIO.new('') d = BiCrypt.new("akey") d.decrypt_stream(crypt2IO, resultIO) resultIO.string.assert == "This is the message!"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bicrypt-1.2.0 | spec/01_example.rdoc |