Sha256: c6ff2f9ad9dc864117d57ce2753d71a4a3d78b7977162e3f945a733b81ce9629

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 QED.rdoc