Skip to content
Browse files

Add better docs

  • Loading branch information...
1 parent 75baf0a commit 473791cc2e96bf4f732c1f8617f94eaff48b1e89 HD Moore committed
Showing with 42 additions and 9 deletions.
  1. +26 −2 README.markdown
  2. +16 −7 lib/fastlib.rb
View
28 README.markdown
@@ -8,10 +8,34 @@ This is similar to capabilities like zip/ziprequire, except that it provides wor
$ apt-get install fastlib
-$ \`gem env gemdir\`/gems/fastlib-\*/lib/fastlib.rb dump lib/myarchive.fastlib lib/ lib/\*
+## Store a library structure into FASTLIB archive
+$ \`gem env gemdir\`/gems/fastlib-\*/lib/fastlib.rb store 00000000 myarchive.fastlib lib/ lib/\*
+$ rm -rf lib
-$ ruby -r rubygems -r fastlib -I lib/myarchive.fastlib application.rb
+## Use that archive just by including the containing directory
+$ ruby -r rubygems -r fastlib -I. ./app.rb
+## Store a library structure into a FASTLIB archive with compression
+$ \`gem env gemdir\`/gems/fastlib-\*/lib/fastlib.rb store 00000001 myarchive.fastlib lib/ lib/\*
+
+## Store a library structure into a FASTLIB archive with default "encryption"
+$ \`gem env gemdir\`/gems/fastlib-\*/lib/fastlib.rb store 00000002 myarchive.fastlib lib/ lib/\*
+
+## Store a library structure into a FASTLIB archive with default "encryption" and compression
+$ \`gem env gemdir\`/gems/fastlib-\*/lib/fastlib.rb store 00000003 myarchive.fastlib lib/ lib/\*
+
+## Store a library structure into a FASTLIB archive with custom encryption and compression
+$ ruby -I . -r mycrypto.rb \`gem env gemdir\`/gems/fastlib-\*/lib/fastlib.rb store 13370003 myarchive.fastlib lib/ lib/\*
+
+$ cat mycrypto.rb
+require 'openssl'
+class FastLib
+def encrypt_13370000(data)
+ # Encrypt
+end
+def decrypt_13370000(data)
+ # Decrypt
+end
# Credits
Rapid7 LLC
View
23 lib/fastlib.rb
@@ -249,22 +249,31 @@ def self.post_process(lib, name, data)
#
# This is a stub crypto handler that performs a basic XOR
- # operation against a fixed one byte key
+ # operation against a fixed one byte key. The two usable IDs
+ # are 12345600 and 00000000
#
def self.encrypt_12345600(data)
- data.unpack("C*").map{ |c| c ^ 0x90 }.pack("C*")
+ encrypt_00000000(data)
end
def self.decrypt_12345600(data)
- encrypt_12345600(data)
+ encrypt_00000000(data)
end
- def self.cache
- @@cache
+ def self.encrypt_00000000(data)
+ data.unpack("C*").map{ |c| c ^ 0x90 }.pack("C*")
end
-
-
+ def self.decrypt_00000000(data)
+ encrypt_00000000(data)
+ end
+
+ #
+ # Expose the cache to callers
+ #
+ def self.cache
+ @@cache
+ end
end

0 comments on commit 473791c

Please sign in to comment.
Something went wrong with that request. Please try again.