rm-digest 0.0.1 → 0.0.2
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.
- data/.gitignore +4 -0
- data/Rakefile +13 -0
- data/app/app_delegate.rb +9 -0
- data/lib/rm-digest.rb +3 -3
- data/lib/rm-digest/md5.rb +3 -1
- data/lib/rm-digest/sha1.rb +3 -1
- data/lib/rm-digest/util.rb +4 -7
- data/lib/rm-digest/version.rb +1 -1
- data/rm-digest.gemspec +1 -1
- data/spec/md5_spec.rb +29 -0
- data/spec/sha1_spec.rb +29 -0
- data/spec/util_spec.rb +8 -0
- metadata +11 -4
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
$:.unshift("/Library/RubyMotion/lib")
|
4
|
+
require 'motion/project'
|
5
|
+
|
6
|
+
#Bundler.setup
|
7
|
+
#Bundler.require
|
8
|
+
|
9
|
+
Motion::Project::App.setup do |app|
|
10
|
+
app.name = 'spec'
|
11
|
+
app.files += Dir.glob(File.join(app.project_dir, 'lib/rm-digest/*.rb'))
|
12
|
+
|
13
|
+
digest_vendor = File.expand_path(File.join(File.dirname(__FILE__), 'vendor/MD5SHA1Digest'))
|
14
|
+
app.vendor_project(digest_vendor, :xcode, headers_dir: 'MD5SHA1Digest')
|
15
|
+
end
|
data/app/app_delegate.rb
ADDED
data/lib/rm-digest.rb
CHANGED
@@ -3,17 +3,17 @@ unless defined?(Motion::Project::Config)
|
|
3
3
|
end
|
4
4
|
|
5
5
|
Motion::Project::App.setup do |app|
|
6
|
+
#app.files.unshift Dir.glob(File.join(app.project_dir, 'app/lib/**/*.rb'))
|
7
|
+
|
6
8
|
Dir.glob(File.join(File.dirname(__FILE__), 'rm-digest/*.rb')).each do |file|
|
7
9
|
app.files.unshift(file)
|
8
10
|
end
|
11
|
+
|
9
12
|
digest_vendor = File.expand_path(File.join(File.dirname(__FILE__), '../vendor/MD5SHA1Digest'))
|
10
13
|
app.vendor_project(digest_vendor, :xcode, headers_dir: 'MD5SHA1Digest')
|
11
14
|
end
|
12
15
|
|
13
16
|
require "rm-digest/version"
|
14
|
-
require File.expand_path('../rm-digest/util', __FILE__)
|
15
|
-
require File.expand_path('../rm-digest/sha1', __FILE__)
|
16
|
-
require File.expand_path('../rm-digest/md5', __FILE__)
|
17
17
|
|
18
18
|
module RmDigest
|
19
19
|
|
data/lib/rm-digest/md5.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module RmDigest
|
2
|
-
|
2
|
+
class MD5
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
def hexdigest(string, encoding = NSUTF8StringEncoding)
|
7
|
+
return nil if string.nil?
|
7
8
|
RmDigest::Util.toNSData(string, encoding).MD5HexDigest
|
8
9
|
end
|
9
10
|
|
10
11
|
def digest(string, encoding = NSUTF8StringEncoding)
|
12
|
+
return nil if string.nil?
|
11
13
|
RmDigest::Util.toNSData(string, encoding).MD5Digest
|
12
14
|
end
|
13
15
|
|
data/lib/rm-digest/sha1.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module RmDigest
|
2
|
-
|
2
|
+
class SHA1
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
def hexdigest(string, encoding = NSUTF8StringEncoding)
|
7
|
+
return nil if string.nil?
|
7
8
|
RmDigest::Util.toNSData(string, encoding).SHA1HexDigest
|
8
9
|
end
|
9
10
|
|
10
11
|
def digest(string, encoding = NSUTF8StringEncoding)
|
12
|
+
return nil if string.nil?
|
11
13
|
RmDigest::Util.toNSData(string, encoding).SHA1Digest
|
12
14
|
end
|
13
15
|
|
data/lib/rm-digest/util.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
module RmDigest
|
2
2
|
|
3
|
-
|
3
|
+
class Util
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def toNSData(string, encoding = NSUTF8StringEncoding)
|
8
|
-
string.dataUsingEncoding(encoding)
|
9
|
-
end
|
10
|
-
|
5
|
+
def self.toNSData(string, encoding = NSUTF8StringEncoding)
|
6
|
+
string.dataUsingEncoding(encoding)
|
11
7
|
end
|
8
|
+
|
12
9
|
end
|
13
10
|
|
14
11
|
end
|
data/lib/rm-digest/version.rb
CHANGED
data/rm-digest.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["tomas@meinlschmidt.com"]
|
7
7
|
gem.description = %q{MD5 and SHA1 Digest}
|
8
8
|
gem.summary = %q{MD5 and SHA1 Digest}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/tmeinlschmidt/rm-digest"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
data/spec/md5_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
describe "MD5 hash" do
|
2
|
+
|
3
|
+
it 'should be true' do
|
4
|
+
true.should == true
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should compute empty md5 hexdigest' do
|
8
|
+
hash = RmDigest::MD5.hexdigest('')
|
9
|
+
hash.should == 'd41d8cd98f00b204e9800998ecf8427e'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should compute md5 nil hexdigest' do
|
13
|
+
hash = RmDigest::MD5.hexdigest(nil)
|
14
|
+
hash.should == nil
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
it 'should compute md5 hexdigest' do
|
19
|
+
hash = RmDigest::MD5.hexdigest('testhash')
|
20
|
+
hash.should == '082949a8dfacccda185a135db425377b'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should compute md5 digest' do
|
24
|
+
hash = RmDigest::MD5.digest('testhash')
|
25
|
+
byte_arr = hash.to_str.each_byte.map{|l| l}
|
26
|
+
byte_arr.should == [8, 41, 73, 168, 223, 172, 204, 218, 24, 90, 19, 93, 180, 37, 55, 123]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/sha1_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
describe "SHA1 hash" do
|
2
|
+
|
3
|
+
it 'should be true' do
|
4
|
+
true.should == true
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should compute empty sha1 hexdigest' do
|
8
|
+
hash = RmDigest::SHA1.hexdigest('')
|
9
|
+
hash.should == 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should compute sha1 nil hexdigest' do
|
13
|
+
hash = RmDigest::SHA1.hexdigest(nil)
|
14
|
+
hash.should == nil
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
it 'should compute sha1 hexdigest' do
|
19
|
+
hash = RmDigest::SHA1.hexdigest('testhash')
|
20
|
+
hash.should == 'f4e5afd5b5449242481ebff8635cf129de2b9b22'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should compute sha1 digest' do
|
24
|
+
hash = RmDigest::SHA1.digest('testhash')
|
25
|
+
byte_arr = hash.to_str.each_byte.map{|l| l}
|
26
|
+
byte_arr.should == [244, 229, 175, 213, 181, 68, 146, 66, 72, 30, 191, 248, 99, 92, 241, 41, 222, 43, 155, 34]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/util_spec.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rm-digest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: MD5 and SHA1 Digest
|
15
15
|
email:
|
@@ -23,12 +23,16 @@ files:
|
|
23
23
|
- LICENSE
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
|
+
- app/app_delegate.rb
|
26
27
|
- lib/rm-digest.rb
|
27
28
|
- lib/rm-digest/md5.rb
|
28
29
|
- lib/rm-digest/sha1.rb
|
29
30
|
- lib/rm-digest/util.rb
|
30
31
|
- lib/rm-digest/version.rb
|
31
32
|
- rm-digest.gemspec
|
33
|
+
- spec/md5_spec.rb
|
34
|
+
- spec/sha1_spec.rb
|
35
|
+
- spec/util_spec.rb
|
32
36
|
- vendor/MD5SHA1Digest/MD5SHA1Digest.bridgesupport
|
33
37
|
- vendor/MD5SHA1Digest/MD5SHA1Digest.xcodeproj/project.pbxproj
|
34
38
|
- vendor/MD5SHA1Digest/MD5SHA1Digest/MD5SHA1Digest-Prefix.pch
|
@@ -36,7 +40,7 @@ files:
|
|
36
40
|
- vendor/MD5SHA1Digest/MD5SHA1Digest/NSData+MD5Digest.m
|
37
41
|
- vendor/MD5SHA1Digest/MD5SHA1Digest/NSData+SHA1Digest.h
|
38
42
|
- vendor/MD5SHA1Digest/MD5SHA1Digest/NSData+SHA1Digest.m
|
39
|
-
homepage:
|
43
|
+
homepage: https://github.com/tmeinlschmidt/rm-digest
|
40
44
|
licenses: []
|
41
45
|
post_install_message:
|
42
46
|
rdoc_options: []
|
@@ -60,4 +64,7 @@ rubygems_version: 1.8.10
|
|
60
64
|
signing_key:
|
61
65
|
specification_version: 3
|
62
66
|
summary: MD5 and SHA1 Digest
|
63
|
-
test_files:
|
67
|
+
test_files:
|
68
|
+
- spec/md5_spec.rb
|
69
|
+
- spec/sha1_spec.rb
|
70
|
+
- spec/util_spec.rb
|