ez_chaff 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +12 -0
- data/lib/ez_chaff.rb +38 -0
- metadata +55 -0
data/README
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
README
|
2
|
+
========================================================================
|
3
|
+
EzChaff provides a simple way of adding chaff to a string in a
|
4
|
+
predictable manner and subsequently removing that chaff.
|
5
|
+
|
6
|
+
Usage
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
gem 'ez_chaff','0.2'
|
10
|
+
require 'ez_chaff'
|
11
|
+
chaffed_string = EzChaff.chaff(string)
|
12
|
+
unchaffed_string = EzChaff.unchaff(string)
|
data/lib/ez_chaff.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module EzChaff
|
2
|
+
|
3
|
+
def self.randomize_full_ascii(length = 10)
|
4
|
+
unless defined?(EzChaff::RANDOM_STRING_SEED)
|
5
|
+
chars = Array.new(126 - 32 + 1,nil)
|
6
|
+
32.upto(126) do |char|
|
7
|
+
chars[char - 32] = char.chr
|
8
|
+
end
|
9
|
+
EzChaff.const_set('RANDOM_STRING_SEED',chars)
|
10
|
+
end
|
11
|
+
chars = EzChaff::RANDOM_STRING_SEED
|
12
|
+
new_string = ""
|
13
|
+
rand_limit = EzChaff::RANDOM_STRING_SEED.size - 1
|
14
|
+
1.upto(length) { |i| new_string << chars[rand(rand_limit)] }
|
15
|
+
return new_string
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.chaff(string)
|
19
|
+
how_much_chaff = string.length
|
20
|
+
chaff = EzChaff.randomize_full_ascii(how_much_chaff)
|
21
|
+
chaffed_string = ''
|
22
|
+
string.length.times do |pos|
|
23
|
+
chaffed_string << "#{string[pos,1]}#{chaff[pos,1]}"
|
24
|
+
end
|
25
|
+
return chaffed_string
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.unchaff(string)
|
29
|
+
unchaffed_string = ''
|
30
|
+
chaff = false
|
31
|
+
string.length.times do |pos|
|
32
|
+
unchaffed_string << string[pos,1] unless chaff
|
33
|
+
chaff = ! chaff
|
34
|
+
end
|
35
|
+
return unchaffed_string
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ez_chaff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.2"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tracy Flynn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-23 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Add/remove chaff in a string
|
17
|
+
email:
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- lib/ez_chaff.rb
|
26
|
+
- README
|
27
|
+
has_rdoc: true
|
28
|
+
homepage:
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.0.1
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: Add/remove chaff in a string
|
54
|
+
test_files: []
|
55
|
+
|