recaptcha-mailhide 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -9
- data/Gemfile.lock +16 -12
- data/README.rdoc +15 -15
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/recaptcha_mailhide/encrypt.rb +23 -5
- data/recaptcha-mailhide.gemspec +11 -11
- data/spec/recaptcha_mailhide/encrypt_spec.rb +4 -0
- metadata +12 -12
data/Gemfile
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
source
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source :rubygems
|
5
2
|
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
3
|
group :development do
|
9
|
-
gem "rspec", "~> 2.
|
10
|
-
gem "bundler", "~> 1.0
|
11
|
-
gem "jeweler", "~> 1.
|
4
|
+
gem "rspec", "~> 2.9.0"
|
5
|
+
gem "bundler", "~> 1.0"
|
6
|
+
gem "jeweler", "~> 1.8.3"
|
12
7
|
end
|
data/Gemfile.lock
CHANGED
@@ -3,24 +3,28 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
diff-lcs (1.1.3)
|
5
5
|
git (1.2.5)
|
6
|
-
jeweler (1.
|
6
|
+
jeweler (1.8.3)
|
7
7
|
bundler (~> 1.0)
|
8
8
|
git (>= 1.2.5)
|
9
9
|
rake
|
10
|
+
rdoc
|
11
|
+
json (1.6.6)
|
10
12
|
rake (0.9.2.2)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rspec-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
rspec-
|
13
|
+
rdoc (3.12)
|
14
|
+
json (~> 1.4)
|
15
|
+
rspec (2.9.0)
|
16
|
+
rspec-core (~> 2.9.0)
|
17
|
+
rspec-expectations (~> 2.9.0)
|
18
|
+
rspec-mocks (~> 2.9.0)
|
19
|
+
rspec-core (2.9.0)
|
20
|
+
rspec-expectations (2.9.1)
|
21
|
+
diff-lcs (~> 1.1.3)
|
22
|
+
rspec-mocks (2.9.0)
|
19
23
|
|
20
24
|
PLATFORMS
|
21
25
|
ruby
|
22
26
|
|
23
27
|
DEPENDENCIES
|
24
|
-
bundler (~> 1.0
|
25
|
-
jeweler (~> 1.
|
26
|
-
rspec (~> 2.
|
28
|
+
bundler (~> 1.0)
|
29
|
+
jeweler (~> 1.8.3)
|
30
|
+
rspec (~> 2.9.0)
|
data/README.rdoc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
=
|
1
|
+
= ReCAPTCHA Mailhide
|
2
2
|
|
3
3
|
This gem provides support for ReCAPTCHA's Mailhide API.
|
4
4
|
|
5
|
-
At the moment it only generates URLs, it doesn't provide any link helpers, so it's completely framework agnostic.
|
5
|
+
At the moment it only generates URLs, it doesn't provide any link helpers, so it's completely framework agnostic (and a bit on the lower side of features).
|
6
6
|
|
7
7
|
== Installation
|
8
8
|
|
@@ -14,21 +14,21 @@ Or if you're using bundler:
|
|
14
14
|
|
15
15
|
gem 'recaptcha-mailhide'
|
16
16
|
|
17
|
-
==
|
17
|
+
== Configuration
|
18
|
+
|
19
|
+
Easy:
|
18
20
|
|
21
|
+
RecaptchaMailhide.configure do |c|
|
22
|
+
c.private_key = 'your private key here'
|
23
|
+
c.public_key = 'your public key here'
|
24
|
+
end
|
25
|
+
|
26
|
+
== Usage
|
19
27
|
|
28
|
+
Call <tt>RecaptchaMailhide::URL.url_for(email)</tt> to get the ReCAPTCHA Mailhide URL.
|
20
29
|
|
21
|
-
|
22
|
-
|
23
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
24
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
25
|
-
* Fork the project
|
26
|
-
* Start a feature/bugfix branch
|
27
|
-
* Commit and push until you are happy with your contribution
|
28
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
29
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
30
|
+
At the moment this gem doesn't provide any helpers to build HTML link tags.
|
30
31
|
|
31
|
-
==
|
32
|
+
== License
|
32
33
|
|
33
|
-
Copyright (c) 2012 Pedro Fayolle.
|
34
|
-
further details.
|
34
|
+
MIT License. Copyright (c) 2012 Pedro Fayolle.
|
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.description = %Q{Ruby implementation of ReCAPTCHA Mailhide's API}
|
22
22
|
gem.email = "pfayolle@gmail.com"
|
23
23
|
gem.authors = ["Pedro Fayolle"]
|
24
|
-
gem.files.include Dir
|
24
|
+
gem.files.include Dir["lib/**/*.rb"]
|
25
25
|
# dependencies defined in Gemfile
|
26
26
|
end
|
27
27
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -6,33 +6,51 @@ module RecaptchaMailhide
|
|
6
6
|
BLOCK_SIZE = 16
|
7
7
|
INITIALIZATION_VECTOR = 0.chr * 16
|
8
8
|
|
9
|
+
# Encrpyts the given string using AES 128 and
|
10
|
+
# returns the result in URL-safe Base64 form.
|
11
|
+
#
|
9
12
|
def self.encrypt(string)
|
10
13
|
aes = build_aes
|
11
|
-
|
12
|
-
urlsafe_base64(encrypted)
|
14
|
+
urlsafe_base64(aes.update(pad_string(string)) + aes.final)
|
13
15
|
end
|
14
16
|
|
15
17
|
private
|
16
18
|
|
19
|
+
# Converts the given string to Base64 encoding,
|
20
|
+
# replacing '+' with '-', '/' with '_' and
|
21
|
+
# removing newlines in order to make it URL-safe.
|
22
|
+
#
|
17
23
|
def self.urlsafe_base64(string)
|
18
|
-
Base64.encode64(string).tr('+/', '-_').
|
24
|
+
Base64.encode64(string).tr('+/', '-_').gsub("\n", '')
|
19
25
|
end
|
20
26
|
|
27
|
+
# Pads the given string to blocks of 16 bytes
|
28
|
+
# using bytes representing the number of bytes
|
29
|
+
# used for padding.
|
30
|
+
#
|
21
31
|
def self.pad_string(string)
|
22
32
|
padding = BLOCK_SIZE - (string.length % BLOCK_SIZE)
|
23
33
|
string + padding.chr * padding
|
24
34
|
end
|
25
35
|
|
36
|
+
# Initializes the cipher.
|
37
|
+
#
|
26
38
|
def self.build_aes
|
27
39
|
aes = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
28
40
|
aes.encrypt
|
29
41
|
aes.iv = INITIALIZATION_VECTOR
|
30
42
|
aes.padding = 0
|
31
43
|
|
32
|
-
|
33
|
-
aes.key = RecaptchaMailhide.configuration.private_key.unpack('a2' * 16).map {|x| x.hex }.pack('c' * 16)
|
44
|
+
aes.key = binary_public_key
|
34
45
|
|
35
46
|
aes
|
36
47
|
end
|
48
|
+
|
49
|
+
# Returns the private key converted from hex
|
50
|
+
# to binary.
|
51
|
+
#
|
52
|
+
def self.binary_public_key
|
53
|
+
RecaptchaMailhide.configuration.private_key.unpack('a2' * 16).map {|x| x.hex }.pack('c' * 16)
|
54
|
+
end
|
37
55
|
end
|
38
56
|
end
|
data/recaptcha-mailhide.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "recaptcha-mailhide"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Pedro Fayolle"]
|
12
|
-
s.date = "2012-04-
|
12
|
+
s.date = "2012-04-18"
|
13
13
|
s.description = "Ruby implementation of ReCAPTCHA Mailhide's API"
|
14
14
|
s.email = "pfayolle@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -45,18 +45,18 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.specification_version = 3
|
46
46
|
|
47
47
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.
|
49
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0
|
50
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.
|
48
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.9.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
51
51
|
else
|
52
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
53
|
-
s.add_dependency(%q<bundler>, ["~> 1.0
|
54
|
-
s.add_dependency(%q<jeweler>, ["~> 1.
|
52
|
+
s.add_dependency(%q<rspec>, ["~> 2.9.0"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
55
55
|
end
|
56
56
|
else
|
57
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
58
|
-
s.add_dependency(%q<bundler>, ["~> 1.0
|
59
|
-
s.add_dependency(%q<jeweler>, ["~> 1.
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 2.9.0"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -9,5 +9,9 @@ describe RecaptchaMailhide::Encrypt do
|
|
9
9
|
it("properly encrypts johndoe@example.com") do
|
10
10
|
RecaptchaMailhide::Encrypt.encrypt("johndoe@example.com").should eq("whWIqk0r4urZ-3S7y7uSceC9_ECd3hpAGy71E2o0HpI=")
|
11
11
|
end
|
12
|
+
|
13
|
+
it("properly encrypts long emails") do
|
14
|
+
RecaptchaMailhide::Encrypt.encrypt("this.sure.is.a.very.long.email.address@example.com").should eq("Ax_miTfkXPP_jPPoe130TlwgEaiBCPUuCxaJy3KalZsWP8_Z_Qcc1Awpwk-cPjVvnsbi6P6Bf_de2U1A5aocVA==")
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recaptcha-mailhide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,41 +9,41 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &15326280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.9.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15326280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &15325280 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.0
|
32
|
+
version: '1.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15325280
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &15323760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
43
|
+
version: 1.8.3
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *15323760
|
47
47
|
description: Ruby implementation of ReCAPTCHA Mailhide's API
|
48
48
|
email: pfayolle@gmail.com
|
49
49
|
executables: []
|
@@ -84,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
segments:
|
86
86
|
- 0
|
87
|
-
hash:
|
87
|
+
hash: 1066762596205955725
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|