encrypted_cookie 0.0.1

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.
Binary file
@@ -0,0 +1,4 @@
1
+ Rakefile
2
+ encrypted_cookie_spec.rb
3
+ lib/encrypted_cookie.rb
4
+ Manifest
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('encrypted_cookie', '0.0.1') do |p|
6
+ p.description = "Encrypted session cookies for Rack"
7
+ p.url = "http://github.com/cvonkleist/encrypted_cookie"
8
+ p.author = "Christian von Kleist"
9
+ p.email = "cvonkleist at-a-place-called gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{encrypted_cookie}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Christian von Kleist"]
9
+ s.cert_chain = ["/home/cvk/.gemcert/gem-public_cert.pem"]
10
+ s.date = %q{2011-03-01}
11
+ s.description = %q{Encrypted session cookies for Rack}
12
+ s.email = %q{cvonkleist at-a-place-called gmail.com}
13
+ s.extra_rdoc_files = ["lib/encrypted_cookie.rb"]
14
+ s.files = ["Rakefile", "encrypted_cookie_spec.rb", "lib/encrypted_cookie.rb", "Manifest", "encrypted_cookie.gemspec"]
15
+ s.homepage = %q{http://github.com/cvonkleist/encrypted_cookie}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Encrypted_cookie"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{encrypted_cookie}
19
+ s.rubygems_version = %q{1.3.7}
20
+ s.signing_key = %q{/home/cvk/.gemcert/gem-private_key.pem}
21
+ s.summary = %q{Encrypted session cookies for Rack}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
+ else
29
+ end
30
+ else
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ require 'encrypted_cookie'
2
+
3
+ include Rack::Session
4
+
5
+ describe Cookie::AES do
6
+ it 'should pass the encryption test' do
7
+ a = Cookie::AES.new('foo')
8
+ enc = a.encode("bar")
9
+ a.decode(enc).should == 'bar'
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ require 'openssl'
2
+
3
+ module Rack
4
+ module Session
5
+ class Cookie
6
+ class AES
7
+ def initialize(key)
8
+ @key = key
9
+ end
10
+
11
+ def encode(str)
12
+ aes = OpenSSL::Cipher::Cipher.new('aes-128-cbc').encrypt
13
+ salt = OpenSSL::Random.random_bytes(aes.key_len)
14
+ iv = OpenSSL::Random.random_bytes(aes.iv_len)
15
+ [iv + (aes.update(str) << aes.final)].pack('m0')
16
+ end
17
+
18
+ def decode(str)
19
+ str = str.unpack('m0').first
20
+ aes = OpenSSL::Cipher::Cipher.new('aes-128-cbc').decrypt
21
+ iv = str[0, aes.iv_len]
22
+ crypted_text = str[aes.iv_len..-1]
23
+ aes.update(crypted_text) << aes.final
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: encrypted_cookie
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Christian von Kleist
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApjdm9u
20
+ a2xlaX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IstpNKnVxkz4Xut3XUsqfCzHUOBnoC
36
+ DnOM3kD7rptG2g==
37
+ -----END CERTIFICATE-----
38
+
39
+ date: 2011-03-01 00:00:00 -05:00
40
+ default_executable:
41
+ dependencies: []
42
+
43
+ description: Encrypted session cookies for Rack
44
+ email: cvonkleist at-a-place-called gmail.com
45
+ executables: []
46
+
47
+ extensions: []
48
+
49
+ extra_rdoc_files:
50
+ - lib/encrypted_cookie.rb
51
+ files:
52
+ - Rakefile
53
+ - encrypted_cookie_spec.rb
54
+ - lib/encrypted_cookie.rb
55
+ - Manifest
56
+ - encrypted_cookie.gemspec
57
+ has_rdoc: true
58
+ homepage: http://github.com/cvonkleist/encrypted_cookie
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --line-numbers
64
+ - --inline-source
65
+ - --title
66
+ - Encrypted_cookie
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 11
84
+ segments:
85
+ - 1
86
+ - 2
87
+ version: "1.2"
88
+ requirements: []
89
+
90
+ rubyforge_project: encrypted_cookie
91
+ rubygems_version: 1.3.7
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Encrypted session cookies for Rack
95
+ test_files: []
96
+
Binary file