This is Oneliner, an online code implementation for Ruby.
See en.wikipedia.org/wiki/Online_codes
Dependencies:
- Oneliner::SuperString
-
openssl: www.openssl.org/
Sub packages:
- Oneliner::SuperString
-
A String subclass that has the added power of Online Coding.
Usage:
You create Oneliner::SuperStrings just regular Strings, then you use Oneliner::SuperString#encode(size_of_chunk) to get Online Coded data from them.
Then you use Oneliner::SuperString#decode!(chunk) on a new Oneliner::SuperString to recreate the data from the original String. Only a few extra percent (around 10 - my randomness seems to be suboptimal) is needed to recreate the original data this way.
Examples:
s = Oneliner::SuperString.new
s2 = Oneliner::SuperString.new(" " * 1024)
redundant_packages = []
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
redundant_packages << s2.encode(256)
index = 0
while index < redundant_packages.size && !s.decode!(redundant_packages[index])
index += 1
end
assert_equal(s2, s)