crypt-rot13 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -7
- data/MANIFEST +7 -9
- data/README +48 -48
- data/Rakefile +22 -0
- data/lib/crypt/rot13.rb +10 -6
- data/test/tc_rot13.rb +9 -14
- metadata +28 -19
data/CHANGES
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
== 1.0.
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
== 1.0.2 - 25-Jul-2007
|
2
|
+
* Changed Rot13Error to Rot13::Error
|
3
|
+
* Added a Rakefile with tasks for installation and testing
|
4
|
+
* Removed the install.rb file. Installation is now handled via a Rake task.
|
5
|
+
* The MANIFEST file was updated and is now rdoc formatted.
|
6
|
+
|
7
|
+
== 1.0.1 - 6-Jun-2005
|
8
|
+
* Moved project to RubyForge.
|
9
|
+
* Minor test and doc changes.
|
10
|
+
* Added a .gemspec file. Gem available online.
|
11
|
+
|
12
|
+
== 1.0.0 - 18-May-2004
|
13
|
+
* Initial release
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
== Description
|
2
|
-
A package for performing simple character rotation (i.e. Caesar Cipher)
|
3
|
-
encryption. There are many like it, but this one is mine.
|
4
|
-
|
5
|
-
== Installation
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
str
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
== Description
|
2
|
+
A package for performing simple character rotation (i.e. Caesar Cipher)
|
3
|
+
encryption. There are many like it, but this one is mine.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
=== Manual Installation
|
7
|
+
rake test (optional)
|
8
|
+
rake install
|
9
|
+
|
10
|
+
=== Gem Installation
|
11
|
+
rake test (optional)
|
12
|
+
rake install_gem
|
13
|
+
|
14
|
+
== Synopsis
|
15
|
+
require 'crypt/rot13'
|
16
|
+
include Crypt
|
17
|
+
|
18
|
+
str = Rot13.new("Hello World", 3) # Caesar cipher
|
19
|
+
puts str # "Khoor Zruog"
|
20
|
+
|
21
|
+
== Notes
|
22
|
+
Not unicode friendly. Only works on ASCII values 65-90 and 97-122.
|
23
|
+
|
24
|
+
== Acknowledgements
|
25
|
+
Thanks go to Gaius Julius Caesar (d. 44 BC) for creating one of the first,
|
26
|
+
and most simple, encryption schemes. Hail Caesar!
|
27
|
+
|
28
|
+
== Known Bugs
|
29
|
+
None that I'm aware of.
|
30
|
+
|
31
|
+
Please log any bugs you find on the SourceForge project page at
|
32
|
+
http://www.rubyforge.org/projects/shards.
|
33
|
+
|
34
|
+
== License
|
35
|
+
Ruby's
|
36
|
+
|
37
|
+
== Copyright
|
38
|
+
(C) 2005-2007, Daniel J. Berger, All Rights Reserved
|
39
|
+
|
40
|
+
== Warranty
|
41
|
+
This package is provided "as is" and without any express or
|
42
|
+
implied warranties, including, without limitation, the implied
|
43
|
+
warranties of merchantability and fitness for a particular purpose.
|
44
|
+
|
45
|
+
== Author
|
46
|
+
Daniel J. Berger
|
47
|
+
djberg96 at nospam at gmail dot com
|
48
|
+
imperator on IRC (irc.freenode.net)
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc "Install the crypt-rot13 package (non-gem)"
|
5
|
+
task :install do
|
6
|
+
dest = File.join(Config::CONFIG['sitelibdir'], 'crypt')
|
7
|
+
Dir.mkdir(dest) unless File.exists? dest
|
8
|
+
cp 'lib/crypt/rot13.rb', dest, :verbose => true
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Install the crypt-rot13 package as a gem"
|
12
|
+
task :install_gem do
|
13
|
+
ruby 'crypt-rot13.gemspec'
|
14
|
+
file = Dir["*.gem"].first
|
15
|
+
sh "gem install #{file}"
|
16
|
+
end
|
17
|
+
|
18
|
+
Rake::TestTask.new do |t|
|
19
|
+
t.libs << 'lib'
|
20
|
+
t.warning = true
|
21
|
+
t.test_files = FileList['test/tc*']
|
22
|
+
end
|
data/lib/crypt/rot13.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Crypt
|
2
|
-
class Rot13Error < ArgumentError; end
|
3
2
|
class Rot13 < String
|
4
|
-
|
3
|
+
class Error < ArgumentError; end
|
4
|
+
|
5
|
+
VERSION = '1.0.2'
|
5
6
|
|
6
7
|
# Returns a new Rot13 object. The object is a string with the letters
|
7
8
|
# each rotated by +degree+.
|
8
9
|
#
|
9
|
-
# You cannot use a multiple of 26 as the degree or a
|
10
|
+
# You cannot use a multiple of 26 as the degree or a Rot13::Error will
|
10
11
|
# be raised. So, your days of double rot13 encryption are over.
|
11
|
-
|
12
|
+
#
|
13
|
+
def initialize(str='', degree=13)
|
12
14
|
unless str.empty?
|
13
15
|
str = rotate_string(str, degree)
|
14
16
|
end
|
@@ -16,15 +18,17 @@ module Crypt
|
|
16
18
|
end
|
17
19
|
|
18
20
|
# Rotates the object by +degree+.
|
21
|
+
#
|
19
22
|
def rotate(degree)
|
20
|
-
rotate_string(self,degree)
|
23
|
+
rotate_string(self, degree)
|
21
24
|
end
|
22
25
|
|
23
26
|
private
|
27
|
+
|
24
28
|
def rotate_string(str,degree)
|
25
29
|
case degree.modulo(26)
|
26
30
|
when 0
|
27
|
-
raise
|
31
|
+
raise Error, "degree must not be a multiple of 26"
|
28
32
|
when 13
|
29
33
|
str.tr!("a-zA-Z","n-za-mN-ZA-M")
|
30
34
|
else
|
data/test/tc_rot13.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
|
-
|
1
|
+
###############################################################
|
2
2
|
# tc_rot13.rb
|
3
3
|
#
|
4
|
-
# Test suite for the crypt-rot13 package.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
10
|
-
end
|
11
|
-
|
12
|
-
require "crypt/rot13"
|
13
|
-
require "test/unit"
|
4
|
+
# Test suite for the crypt-rot13 package. You should run this
|
5
|
+
# test case via the 'rake test' task.
|
6
|
+
###############################################################
|
7
|
+
require 'crypt/rot13'
|
8
|
+
require 'test/unit'
|
14
9
|
include Crypt
|
15
10
|
|
16
11
|
class TC_Rot13 < Test::Unit::TestCase
|
@@ -27,7 +22,7 @@ class TC_Rot13 < Test::Unit::TestCase
|
|
27
22
|
end
|
28
23
|
|
29
24
|
def test_version
|
30
|
-
assert_equal(
|
25
|
+
assert_equal('1.0.2', Rot13::VERSION)
|
31
26
|
end
|
32
27
|
|
33
28
|
def test_constructor
|
@@ -42,8 +37,8 @@ class TC_Rot13 < Test::Unit::TestCase
|
|
42
37
|
end
|
43
38
|
|
44
39
|
def test_degree
|
45
|
-
assert_raises(
|
46
|
-
assert_raises(
|
40
|
+
assert_raises(Rot13::Error){ Rot13.new("foo",26) }
|
41
|
+
assert_raises(Rot13::Error){ Rot13.new("foo",52) }
|
47
42
|
assert_nothing_raised{ Rot13.new("foo",25) }
|
48
43
|
end
|
49
44
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: crypt-rot13
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date:
|
8
|
-
summary:
|
6
|
+
version: 1.0.2
|
7
|
+
date: 2007-07-25 00:00:00 -06:00
|
8
|
+
summary: Character rotation encryption, i.e. Caesar Cipher
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: djberg96@gmail.com
|
12
12
|
homepage: http://www.rubyforge.org/projects/shards
|
13
13
|
rubyforge_project:
|
@@ -18,27 +18,36 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
27
29
|
authors:
|
28
|
-
|
30
|
+
- Daniel J. Berger
|
29
31
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
- lib/crypt/rot13.rb
|
33
|
+
- CHANGES
|
34
|
+
- MANIFEST
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- test/tc_rot13.rb
|
35
38
|
test_files:
|
36
|
-
|
39
|
+
- test/tc_rot13.rb
|
37
40
|
rdoc_options: []
|
41
|
+
|
38
42
|
extra_rdoc_files:
|
39
|
-
|
40
|
-
|
43
|
+
- README
|
44
|
+
- CHANGES
|
45
|
+
- MANIFEST
|
41
46
|
executables: []
|
47
|
+
|
42
48
|
extensions: []
|
49
|
+
|
43
50
|
requirements: []
|
44
|
-
|
51
|
+
|
52
|
+
dependencies: []
|
53
|
+
|