bkerley-affine 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'yaml'
3
4
 
4
5
  begin
5
6
  require 'jeweler'
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 0
4
4
  :minor: 2
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{affine}
5
- s.version = "0.2.2"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bryce Kerley"]
9
- s.date = %q{2009-06-10}
9
+ s.date = %q{2009-06-16}
10
10
  s.email = %q{bkerley@brycekerley.net}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -41,7 +41,7 @@ module Affine
41
41
  #
42
42
  # == Argument
43
43
  # [+ciphertext+] a single positive integer between 0 and the +modulus+
44
- # for the cipher
44
+ # for the cipher
45
45
  def decipher(ciphertext)
46
46
  raise RangeError.new(ciphertext, @modulus) if ciphertext > @modulus
47
47
  (@a_inv * (ciphertext - @b_key)) % @modulus
@@ -14,16 +14,16 @@ class AffineTest < Test::Unit::TestCase
14
14
 
15
15
  should 'encipher ITSCOOL correctly' do
16
16
  # example from http://en.wikipedia.org/wiki/Affine_cipher
17
- plain = 'ITSCOOL'.split('').map{ |c| c[0] - 65}
17
+ plain = 'ITSCOOL'.unpack('CCCCCCC').map{ |c| c - 65}
18
18
  coded = plain.map{ |c| @a.encipher c }
19
- check ='WZUSAAL'.split('').map{ |c| c[0] - 65}
19
+ check ='WZUSAAL'.unpack('CCCCCCC').map{ |c| c - 65}
20
20
  assert_equal check, coded
21
21
  end
22
22
  should 'decipiher WZUSAAL correctly' do
23
23
  # example from http://en.wikipedia.org/wiki/Affine_cipher
24
- check ='WZUSAAL'.split('').map{ |c| c[0] - 65}
24
+ check ='WZUSAAL'.unpack('CCCCCCC').map{ |c| c - 65}
25
25
  coded = check.map{ |c| @a.decipher c }
26
- plain = 'ITSCOOL'.split('').map{ |c| c[0] - 65}
26
+ plain = 'ITSCOOL'.unpack('CCCCCCC').map{ |c| c - 65}
27
27
  assert_equal plain, coded
28
28
  end
29
29
  end
@@ -41,7 +41,7 @@ class AffineTest < Test::Unit::TestCase
41
41
  # I'm not doing this by hand
42
42
  1000.times do
43
43
  r = rand(123235150)
44
- assert_equal r, @a.decipher(@a.encipher r)
44
+ assert_equal r, @a.decipher(@a.encipher(r))
45
45
  end
46
46
  end
47
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bkerley-affine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryce Kerley
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-10 00:00:00 -07:00
12
+ date: 2009-06-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15