rmega 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +82 -0
- data/Rakefile +2 -0
- data/lib/rmega.rb +50 -0
- data/lib/rmega/crypto/aes.rb +33 -0
- data/lib/rmega/crypto/aes_ctr.rb +89 -0
- data/lib/rmega/crypto/crypto.rb +94 -0
- data/lib/rmega/crypto/rsa.rb +19 -0
- data/lib/rmega/crypto/rsa_mega.js +455 -0
- data/lib/rmega/node.rb +128 -0
- data/lib/rmega/session.rb +78 -0
- data/lib/rmega/storage.rb +146 -0
- data/lib/rmega/utils.rb +197 -0
- data/lib/rmega/version.rb +3 -0
- data/rmega.gemspec +23 -0
- data/spec/rmega/lib/crypto/aes_spec.rb +12 -0
- data/spec/rmega/lib/crypto/crypto_spec.rb +27 -0
- data/spec/rmega/lib/utils_spec.rb +66 -0
- data/spec/spec_helper.rb +12 -0
- metadata +150 -0
data/rmega.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rmega/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Daniele Molteni"]
|
6
|
+
gem.email = ["dani.m.mobile@gmail.com"]
|
7
|
+
gem.description = %q{mega.co.nz ruby api}
|
8
|
+
gem.summary = %q{mega.co.nz ruby api}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rmega"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rmega::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "pry"
|
19
|
+
gem.add_development_dependency "rspec"
|
20
|
+
gem.add_dependency "httpclient"
|
21
|
+
gem.add_dependency "ruby-progressbar"
|
22
|
+
gem.add_dependency "execjs"
|
23
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rmega::Crypto::Aes do
|
4
|
+
describe '#encrypt' do
|
5
|
+
it 'returns the expect result' do
|
6
|
+
data = [447236115, -1585310199, -1864656235, -1137211605]
|
7
|
+
key = [1380895471, 1656741118, 372674858, 886637722]
|
8
|
+
result = [-1780228062, 945709550, 1098116349, -1813988988]
|
9
|
+
described_class.encrypt(key, data).should == result
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rmega::Crypto do
|
4
|
+
describe '#prepare_key' do
|
5
|
+
it 'returns the expected value' do
|
6
|
+
data = [1684081408, -1313687523, 845282884, -1735274811]
|
7
|
+
result = [1380895471, 1656741118, 372674858, 886637722]
|
8
|
+
described_class.prepare_key(data).should == result
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#prepare_key_pw' do
|
13
|
+
it 'returns the expected value' do
|
14
|
+
password = "my kingdom 4 a horse"
|
15
|
+
result = [-24267049, 354638668, -845953520, 1348163508]
|
16
|
+
described_class.prepare_key_pw(password).should == result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#stringhash' do
|
21
|
+
it 'returns the expected value' do
|
22
|
+
string = 'sjobs@apple.com'
|
23
|
+
key = [-812846736, -655070268, -844240819, 1006009750]
|
24
|
+
described_class.stringhash(key, string).should == 'snWuwnlz45w'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Rmega::Utils do
|
5
|
+
describe '#str_to_a32' do
|
6
|
+
it 'returns the expected value' do
|
7
|
+
string = 'johnsnow'
|
8
|
+
a32 = [1785686126, 1936617335]
|
9
|
+
described_class.str_to_a32(string).should == a32
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns the expected value' do
|
13
|
+
string = 'sjobs@apple.com'
|
14
|
+
a32 = [1936355170, 1933599088, 1886151982, 1668246784]
|
15
|
+
described_class.str_to_a32(string).should == a32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#a32_to_str' do
|
20
|
+
it 'returns the expected value' do
|
21
|
+
a32 = [1953853537, 1660944384]
|
22
|
+
string = "tupac" + "\x00\x00\x00"
|
23
|
+
described_class.a32_to_str(a32).should == string
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#base64urlencode' do
|
28
|
+
it 'returns the expected value' do
|
29
|
+
string = 'ice_lord'
|
30
|
+
result = 'aWNlX2xvcmQ'
|
31
|
+
described_class.base64urlencode(string).should == result
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#a32_to_base64' do
|
36
|
+
it 'returns the expected value' do
|
37
|
+
a32 = [-24267049, 354638668, -845953520, 1348163508]
|
38
|
+
result = '_o221xUjW0zNk8YQUFtXtA'
|
39
|
+
described_class.a32_to_base64(a32).should == result
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#base64urldecode' do
|
44
|
+
it 'returns the expected value' do
|
45
|
+
encoded_value = "c29ycnkgaSBhbSBidXN5"
|
46
|
+
result = "sorry i am busy"
|
47
|
+
described_class.base64urldecode(encoded_value).should == result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#base64_to_a32' do
|
52
|
+
it 'returns the expected value' do
|
53
|
+
encoded_value = "YmF0dGxlc3RhciBnYWxhY3RpY2E"
|
54
|
+
result = [1650553972, 1818588020, 1634869351, 1634492771, 1953063777]
|
55
|
+
described_class.base64_to_a32(encoded_value).should == result
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#b2s' do
|
60
|
+
it 'returns the expected value' do
|
61
|
+
value = [123, 213123, 321354, 5435, 4545, 23434, 6665656]
|
62
|
+
result = [1706407936, 95985664, 297861121, 1404044519, 1241527304, 805306491]
|
63
|
+
described_class.str_to_a32(described_class.b2s(value)).should == result
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rmega
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniele Molteni
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pry
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: httpclient
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: ruby-progressbar
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: execjs
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: mega.co.nz ruby api
|
95
|
+
email:
|
96
|
+
- dani.m.mobile@gmail.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Gemfile
|
103
|
+
- LICENSE
|
104
|
+
- README.md
|
105
|
+
- Rakefile
|
106
|
+
- lib/rmega.rb
|
107
|
+
- lib/rmega/crypto/aes.rb
|
108
|
+
- lib/rmega/crypto/aes_ctr.rb
|
109
|
+
- lib/rmega/crypto/crypto.rb
|
110
|
+
- lib/rmega/crypto/rsa.rb
|
111
|
+
- lib/rmega/crypto/rsa_mega.js
|
112
|
+
- lib/rmega/node.rb
|
113
|
+
- lib/rmega/session.rb
|
114
|
+
- lib/rmega/storage.rb
|
115
|
+
- lib/rmega/utils.rb
|
116
|
+
- lib/rmega/version.rb
|
117
|
+
- rmega.gemspec
|
118
|
+
- spec/rmega/lib/crypto/aes_spec.rb
|
119
|
+
- spec/rmega/lib/crypto/crypto_spec.rb
|
120
|
+
- spec/rmega/lib/utils_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
homepage: ''
|
123
|
+
licenses: []
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 1.8.24
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: mega.co.nz ruby api
|
146
|
+
test_files:
|
147
|
+
- spec/rmega/lib/crypto/aes_spec.rb
|
148
|
+
- spec/rmega/lib/crypto/crypto_spec.rb
|
149
|
+
- spec/rmega/lib/utils_spec.rb
|
150
|
+
- spec/spec_helper.rb
|