ruby-rc4 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +12 -0
  2. data/spec/rc4_spec.rb +60 -0
  3. metadata +50 -30
data/README.md CHANGED
@@ -36,3 +36,15 @@ packaged it using gem-this.
36
36
  I switched the project to use rspec2 and am the now the project's primary maintainer.
37
37
 
38
38
  Caige Nichols <caigesn@gmail.com>
39
+
40
+ # License
41
+
42
+ Ruby-RC4 is released under the MIT license.
43
+
44
+ # Contributors
45
+
46
+ (Please let me know if I missed anyone)
47
+
48
+ - [caiges](http://github.com/caiges)
49
+ - [juggler](http://github.com/juggler) (original author)
50
+ - Alexandar Simic
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: ascii
3
+
4
+ require 'rc4'
5
+ require 'rspec'
6
+
7
+ describe RC4 do
8
+ it "should not crypt with a blank key" do
9
+ expect {
10
+ RC4.new("")
11
+ }.to raise_error(SyntaxError, "RC4: Key supplied is blank")
12
+
13
+ end
14
+
15
+ it "should encrypt and decrypt password 'super-cool-test' with key 'nuff rspec'" do
16
+ key = "nuff rspec"
17
+ enc = RC4.new(key)
18
+ encrypted = enc.encrypt("super-cool-test")
19
+
20
+ dec = RC4.new(key)
21
+ decrypted = dec.decrypt(encrypted)
22
+ decrypted.should match(/super-cool-test/)
23
+ end
24
+
25
+ it "should encrypt and decrypt password 'if-I-was-a-bit' with key 'bitsnbytes'" do
26
+ enc = RC4.new('bitsnbytes')
27
+ dec = RC4.new('bitsnbytes')
28
+
29
+ encrypted = enc.encrypt("if-I-was-a-bit")
30
+ decrypted = dec.decrypt(encrypted)
31
+ decrypted.should match(/if-I-was-a-bit/)
32
+ end
33
+
34
+
35
+ # test samples taken from:
36
+ # http://en.wikipedia.org/wiki/RC4#Test_vectors
37
+
38
+ it "should decrypt ciphertext 'BBF316E8D940AF0AD3' with key 'Key' to 'Plaintext'" do
39
+ dec = RC4.new('Key')
40
+
41
+ decrypted = dec.decrypt(['BBF316E8D940AF0AD3'].pack("H*"))
42
+ decrypted.should match(/Plaintext/)
43
+ end
44
+
45
+ it "should decrypt ciphertext '1021BF0420' with key 'Wiki' to 'pedia' " do
46
+ dec = RC4.new('Wiki')
47
+
48
+ decrypted = dec.decrypt(['1021BF0420'].pack("H*"))
49
+ decrypted.should match(/pedia/)
50
+ end
51
+
52
+ it "should decrypt ciphertext '45A01F645FC35B383552544B9BF5' with key 'Secret' to 'Attack at dawn'" do
53
+ dec = RC4.new('Secret')
54
+
55
+ decrypted = dec.decrypt(['45A01F645FC35B383552544B9BF5'].pack("H*"))
56
+ decrypted.should match(/Attack at dawn/)
57
+ end
58
+ end
59
+
60
+
metadata CHANGED
@@ -1,64 +1,84 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-rc4
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 4
10
+ version: 0.1.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Caige Nichols
9
- - James Healy
10
14
  autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
- date: 2011-08-15 00:00:00.000000000 -07:00
17
+
18
+ date: 2012-01-25 00:00:00 -07:00
14
19
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
17
22
  name: rspec
18
- requirement: &70216958367680 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
19
25
  none: false
20
- requirements:
21
- - - ! '>='
22
- - !ruby/object:Gem::Version
23
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
24
33
  type: :development
25
- prerelease: false
26
- version_requirements: *70216958367680
34
+ version_requirements: *id001
27
35
  description:
28
36
  email: caigesn@gmail.com
29
37
  executables: []
38
+
30
39
  extensions: []
31
- extra_rdoc_files:
40
+
41
+ extra_rdoc_files:
32
42
  - README.md
33
- files:
43
+ files:
34
44
  - README.md
35
45
  - Rakefile
36
46
  - lib/rc4.rb
47
+ - spec/rc4_spec.rb
37
48
  has_rdoc: true
38
49
  homepage: http://www.caigenichols.com/
39
50
  licenses: []
51
+
40
52
  post_install_message:
41
- rdoc_options:
53
+ rdoc_options:
42
54
  - --main
43
55
  - README.md
44
- require_paths:
56
+ require_paths:
45
57
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
58
+ required_ruby_version: !ruby/object:Gem::Requirement
47
59
  none: false
48
- requirements:
49
- - - ! '>='
50
- - !ruby/object:Gem::Version
51
- version: '0'
52
- required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
68
  none: false
54
- requirements:
55
- - - ! '>='
56
- - !ruby/object:Gem::Version
57
- version: '0'
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
58
76
  requirements: []
77
+
59
78
  rubyforge_project: ruby-rc4
60
79
  rubygems_version: 1.6.2
61
80
  signing_key:
62
81
  specification_version: 3
63
82
  summary: RubyRC4 is a pure Ruby implementation of the RC4 algorithm.
64
- test_files: []
83
+ test_files:
84
+ - spec/rc4_spec.rb