swaggard 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-700.eot +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-700.svg +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-700.ttf +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-700.woff +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-700.woff2 +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-regular.eot +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-regular.svg +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-regular.ttf +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-regular.woff +0 -0
- data/app/assets/fonts/swaggard/droid-sans-v6-latin-regular.woff2 +0 -0
- data/app/assets/images/swaggard/explorer_icons.png +0 -0
- data/app/assets/images/swaggard/favicon-16x16.png +0 -0
- data/app/assets/images/swaggard/favicon-32x32.png +0 -0
- data/app/assets/images/swaggard/favicon.ico +0 -0
- data/app/assets/images/swaggard/logo_small.png +0 -0
- data/app/assets/images/swaggard/pet_store_api.png +0 -0
- data/app/assets/images/swaggard/throbber.gif +0 -0
- data/app/assets/images/swaggard/wordnik_api.png +0 -0
- data/app/assets/javascripts/swaggard/application.js +12 -12
- data/app/assets/javascripts/swaggard/lib/backbone-min.js +0 -0
- data/app/assets/javascripts/swaggard/lib/handlebars-2.0.0.js +0 -0
- data/app/assets/javascripts/swaggard/lib/highlight.7.3.pack.js +0 -0
- data/app/assets/javascripts/swaggard/lib/jquery-1.8.0.min.js +1 -1
- data/app/assets/javascripts/swaggard/lib/jquery.ba-bbq.min.js +0 -0
- data/app/assets/javascripts/swaggard/lib/jquery.slideto.min.js +0 -0
- data/app/assets/javascripts/swaggard/lib/jquery.wiggle.min.js +0 -0
- data/app/assets/javascripts/swaggard/lib/marked.js +0 -0
- data/app/assets/javascripts/swaggard/lib/swagger-oauth.js +290 -0
- data/app/assets/javascripts/swaggard/lib/underscore-min.js +6 -32
- data/app/assets/javascripts/swaggard/lib/underscore-min.map +1 -0
- data/app/assets/javascripts/swaggard/swaggard.js +59 -0
- data/app/assets/javascripts/swaggard/swagger-ui.js +31404 -1363
- data/app/assets/stylesheets/swaggard/application.css +1 -1
- data/app/assets/stylesheets/swaggard/application_print.css +15 -0
- data/app/assets/stylesheets/swaggard/print.css.scss +1175 -0
- data/app/assets/stylesheets/swaggard/reset.css +0 -0
- data/app/assets/stylesheets/swaggard/screen.css.scss +41 -15
- data/app/assets/stylesheets/swaggard/typography.css.scss +2 -1
- data/app/controllers/swaggard/swagger_controller.rb +3 -1
- data/app/views/swaggard/swagger/index.html.erb +30 -71
- data/config/initializers/assets.rb +1 -0
- data/lib/swaggard.rb +13 -7
- data/lib/swaggard/api_definition.rb +3 -1
- data/lib/swaggard/configuration.rb +18 -6
- data/lib/swaggard/engine.rb +8 -2
- data/lib/swaggard/parsers/controllers.rb +0 -2
- data/lib/swaggard/parsers/models.rb +1 -1
- data/lib/swaggard/swagger/default_response.rb +17 -0
- data/lib/swaggard/swagger/definition.rb +3 -1
- data/lib/swaggard/swagger/operation.rb +3 -0
- data/lib/swaggard/swagger/parameters/body.rb +4 -2
- data/lib/swaggard/swagger/parameters/query.rb +13 -1
- data/lib/swaggard/swagger/response.rb +14 -6
- data/lib/swaggard/swagger/type.rb +27 -42
- data/lib/swaggard/version.rb +1 -1
- data/spec/fixtures/api.json +1 -1
- data/spec/fixtures/dummy/app/controllers/admin/pets_controller.rb +11 -0
- data/spec/fixtures/dummy/config/routes.rb +4 -1
- data/spec/fixtures/swagger_schema.json +1495 -0
- data/spec/integration/swaggard_spec.rb +8 -4
- data/spec/spec_helper.rb +0 -1
- metadata +17 -8
- data/app/assets/javascripts/swaggard/lib/MD5.js +0 -319
- data/app/assets/javascripts/swaggard/lib/handlebars-1.0.rc.1.js +0 -1920
- data/app/assets/javascripts/swaggard/lib/shred.bundle.js +0 -2765
- data/app/assets/javascripts/swaggard/lib/swagger-client.js +0 -3294
- data/app/assets/javascripts/swaggard/lib/swagger.js +0 -794
- data/app/assets/javascripts/swaggard/swagger-ui_org.js +0 -2005
@@ -1,19 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
require 'json-schema'
|
4
|
+
|
3
5
|
describe Swaggard, '.get_doc' do
|
4
6
|
|
5
|
-
let(:controller_path) { File.expand_path('../../fixtures/dummy/app/controllers
|
7
|
+
let(:controller_path) { File.expand_path('../../fixtures/dummy/app/controllers/**/*.rb', __FILE__) }
|
6
8
|
let(:api_json) { File.read(File.expand_path('../../fixtures/api.json', __FILE__)) }
|
7
9
|
|
8
|
-
|
10
|
+
let(:host) { 'localhost:3000' }
|
11
|
+
|
12
|
+
it 'generates the expected swagger json' do
|
9
13
|
Swaggard.configure do |config|
|
10
14
|
config.controllers_path = controller_path
|
11
15
|
config.routes = Dummy::Application.routes.routes
|
12
16
|
end
|
13
17
|
|
14
|
-
swagger_json = JSON.dump(Swaggard.get_doc)
|
18
|
+
swagger_json = JSON.dump(Swaggard.get_doc(host))
|
15
19
|
|
16
20
|
expect(swagger_json).to eq(api_json)
|
17
21
|
end
|
18
22
|
|
19
|
-
end
|
23
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,7 +17,6 @@ require File.expand_path('../fixtures/dummy/config/application.rb', __FILE__)
|
|
17
17
|
# Dir["./spec/support/**/*.rb"].each {|f| require f}
|
18
18
|
|
19
19
|
RSpec.configure do |config|
|
20
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
21
20
|
config.run_all_when_everything_filtered = true
|
22
21
|
config.filter_run :focus
|
23
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swaggard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -114,14 +114,16 @@ files:
|
|
114
114
|
- app/assets/fonts/swaggard/droid-sans-v6-latin-regular.ttf
|
115
115
|
- app/assets/fonts/swaggard/droid-sans-v6-latin-regular.woff
|
116
116
|
- app/assets/fonts/swaggard/droid-sans-v6-latin-regular.woff2
|
117
|
+
- app/assets/images/swaggard/explorer_icons.png
|
118
|
+
- app/assets/images/swaggard/favicon-16x16.png
|
119
|
+
- app/assets/images/swaggard/favicon-32x32.png
|
120
|
+
- app/assets/images/swaggard/favicon.ico
|
117
121
|
- app/assets/images/swaggard/logo_small.png
|
118
122
|
- app/assets/images/swaggard/pet_store_api.png
|
119
123
|
- app/assets/images/swaggard/throbber.gif
|
120
124
|
- app/assets/images/swaggard/wordnik_api.png
|
121
125
|
- app/assets/javascripts/swaggard/application.js
|
122
|
-
- app/assets/javascripts/swaggard/lib/MD5.js
|
123
126
|
- app/assets/javascripts/swaggard/lib/backbone-min.js
|
124
|
-
- app/assets/javascripts/swaggard/lib/handlebars-1.0.rc.1.js
|
125
127
|
- app/assets/javascripts/swaggard/lib/handlebars-2.0.0.js
|
126
128
|
- app/assets/javascripts/swaggard/lib/highlight.7.3.pack.js
|
127
129
|
- app/assets/javascripts/swaggard/lib/jquery-1.8.0.min.js
|
@@ -129,19 +131,21 @@ files:
|
|
129
131
|
- app/assets/javascripts/swaggard/lib/jquery.slideto.min.js
|
130
132
|
- app/assets/javascripts/swaggard/lib/jquery.wiggle.min.js
|
131
133
|
- app/assets/javascripts/swaggard/lib/marked.js
|
132
|
-
- app/assets/javascripts/swaggard/lib/
|
133
|
-
- app/assets/javascripts/swaggard/lib/swagger-client.js
|
134
|
-
- app/assets/javascripts/swaggard/lib/swagger.js
|
134
|
+
- app/assets/javascripts/swaggard/lib/swagger-oauth.js
|
135
135
|
- app/assets/javascripts/swaggard/lib/underscore-min.js
|
136
|
+
- app/assets/javascripts/swaggard/lib/underscore-min.map
|
137
|
+
- app/assets/javascripts/swaggard/swaggard.js
|
136
138
|
- app/assets/javascripts/swaggard/swagger-ui.js
|
137
|
-
- app/assets/javascripts/swaggard/swagger-ui_org.js
|
138
139
|
- app/assets/stylesheets/swaggard/application.css
|
140
|
+
- app/assets/stylesheets/swaggard/application_print.css
|
141
|
+
- app/assets/stylesheets/swaggard/print.css.scss
|
139
142
|
- app/assets/stylesheets/swaggard/reset.css
|
140
143
|
- app/assets/stylesheets/swaggard/screen.css.scss
|
141
144
|
- app/assets/stylesheets/swaggard/typography.css.scss
|
142
145
|
- app/controllers/swaggard/application_controller.rb
|
143
146
|
- app/controllers/swaggard/swagger_controller.rb
|
144
147
|
- app/views/swaggard/swagger/index.html.erb
|
148
|
+
- config/initializers/assets.rb
|
145
149
|
- config/routes.rb
|
146
150
|
- lib/swaggard.rb
|
147
151
|
- lib/swaggard/api_definition.rb
|
@@ -150,6 +154,7 @@ files:
|
|
150
154
|
- lib/swaggard/parsers/controllers.rb
|
151
155
|
- lib/swaggard/parsers/models.rb
|
152
156
|
- lib/swaggard/parsers/routes.rb
|
157
|
+
- lib/swaggard/swagger/default_response.rb
|
153
158
|
- lib/swaggard/swagger/definition.rb
|
154
159
|
- lib/swaggard/swagger/operation.rb
|
155
160
|
- lib/swaggard/swagger/parameters/base.rb
|
@@ -165,12 +170,14 @@ files:
|
|
165
170
|
- lib/swaggard/swagger/type.rb
|
166
171
|
- lib/swaggard/version.rb
|
167
172
|
- spec/fixtures/api.json
|
173
|
+
- spec/fixtures/dummy/app/controllers/admin/pets_controller.rb
|
168
174
|
- spec/fixtures/dummy/app/controllers/application_controller.rb
|
169
175
|
- spec/fixtures/dummy/app/controllers/pets_controller.rb
|
170
176
|
- spec/fixtures/dummy/config/application.rb
|
171
177
|
- spec/fixtures/dummy/config/environments/development.rb
|
172
178
|
- spec/fixtures/dummy/config/routes.rb
|
173
179
|
- spec/fixtures/dummy/log/development.log
|
180
|
+
- spec/fixtures/swagger_schema.json
|
174
181
|
- spec/integration/swaggard_spec.rb
|
175
182
|
- spec/spec_helper.rb
|
176
183
|
homepage: https://github.com/Moove-it/swaggard
|
@@ -199,12 +206,14 @@ specification_version: 4
|
|
199
206
|
summary: 'Swaggard: Swagger Rails REST API doc using yard YARD'
|
200
207
|
test_files:
|
201
208
|
- spec/fixtures/api.json
|
209
|
+
- spec/fixtures/dummy/app/controllers/admin/pets_controller.rb
|
202
210
|
- spec/fixtures/dummy/app/controllers/application_controller.rb
|
203
211
|
- spec/fixtures/dummy/app/controllers/pets_controller.rb
|
204
212
|
- spec/fixtures/dummy/config/application.rb
|
205
213
|
- spec/fixtures/dummy/config/environments/development.rb
|
206
214
|
- spec/fixtures/dummy/config/routes.rb
|
207
215
|
- spec/fixtures/dummy/log/development.log
|
216
|
+
- spec/fixtures/swagger_schema.json
|
208
217
|
- spec/integration/swaggard_spec.rb
|
209
218
|
- spec/spec_helper.rb
|
210
219
|
has_rdoc:
|
@@ -1,319 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Javascript MD5 library - version 0.4 (Modified)
|
3
|
-
|
4
|
-
Coded (2011) by Luigi Galli - LG@4e71.org - http://faultylabs.com
|
5
|
-
Thanks to: Roberto Viola
|
6
|
-
Modified at SyncTV, Inc. 2012 to employ AMD module loading and not uppercase result string.
|
7
|
-
|
8
|
-
The below code is PUBLIC DOMAIN - NO WARRANTY!
|
9
|
-
*/
|
10
|
-
|
11
|
-
/**
|
12
|
-
* @name MD5
|
13
|
-
* @namespace Utility for dealing with MD5 hashes.
|
14
|
-
*/
|
15
|
-
|
16
|
-
/**
|
17
|
-
@name hash
|
18
|
-
@memberof MD5
|
19
|
-
@function
|
20
|
-
@description Computes the MD5 hash for the given input data
|
21
|
-
|
22
|
-
@param {String|String[]|Number[]|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array} data
|
23
|
-
data as String - (Assumes Unicode code points are encoded as UTF-8. If you
|
24
|
-
attempt to digest Unicode strings using other encodings
|
25
|
-
you will get incorrect results!)
|
26
|
-
<br />
|
27
|
-
data as array of characters - (Assumes Unicode code points are encoded as UTF-8. If you
|
28
|
-
attempt to digest Unicode strings using other encodings
|
29
|
-
you will get incorrect results!)
|
30
|
-
<br />
|
31
|
-
data as array of bytes (plain javascript array of integer numbers)
|
32
|
-
<br />
|
33
|
-
data as ArrayBuffer (see: https://developer.mozilla.org/en/JavaScript_typed_arrays)
|
34
|
-
<br />
|
35
|
-
data as Float32Array, Float64Array, Int16Array, Int32Array, Int8Array, Uint16Array, Uint32Array or Uint8Array (see: https://developer.mozilla.org/en/JavaScript_typed_arrays)
|
36
|
-
|
37
|
-
@returns {String} MD5 hash as lowercase hex string.
|
38
|
-
*/
|
39
|
-
|
40
|
-
var MD5 = {};
|
41
|
-
MD5.hash = function(data) {
|
42
|
-
|
43
|
-
// convert number to (unsigned) 32 bit hex, zero filled string
|
44
|
-
function to_zerofilled_hex(n) {
|
45
|
-
var t1 = (n >>> 0).toString(16)
|
46
|
-
return "00000000".substr(0, 8 - t1.length) + t1
|
47
|
-
}
|
48
|
-
|
49
|
-
// convert array of chars to array of bytes
|
50
|
-
function chars_to_bytes(ac) {
|
51
|
-
var retval = []
|
52
|
-
for(var i = 0; i < ac.length; i++) {
|
53
|
-
retval = retval.concat(str_to_bytes(ac[i]))
|
54
|
-
}
|
55
|
-
return retval
|
56
|
-
}
|
57
|
-
|
58
|
-
// convert a 64 bit unsigned number to array of bytes. Little endian
|
59
|
-
function int64_to_bytes(num) {
|
60
|
-
var retval = []
|
61
|
-
for(var i = 0; i < 8; i++) {
|
62
|
-
retval.push(num & 0xFF)
|
63
|
-
num = num >>> 8
|
64
|
-
}
|
65
|
-
return retval
|
66
|
-
}
|
67
|
-
|
68
|
-
// 32 bit left-rotation
|
69
|
-
function rol(num, places) {
|
70
|
-
return ((num << places) & 0xFFFFFFFF) | (num >>> (32 - places))
|
71
|
-
}
|
72
|
-
|
73
|
-
// The 4 MD5 functions
|
74
|
-
function fF(b, c, d) {
|
75
|
-
return (b & c) | (~b & d)
|
76
|
-
}
|
77
|
-
|
78
|
-
function fG(b, c, d) {
|
79
|
-
return (d & b) | (~d & c)
|
80
|
-
}
|
81
|
-
|
82
|
-
function fH(b, c, d) {
|
83
|
-
return b ^ c ^ d
|
84
|
-
}
|
85
|
-
|
86
|
-
function fI(b, c, d) {
|
87
|
-
return c ^ (b | ~d)
|
88
|
-
}
|
89
|
-
|
90
|
-
// pick 4 bytes at specified offset. Little-endian is assumed
|
91
|
-
function bytes_to_int32(arr, off) {
|
92
|
-
return (arr[off + 3] << 24) | (arr[off + 2] << 16) | (arr[off + 1] << 8) | (arr[off])
|
93
|
-
}
|
94
|
-
|
95
|
-
/*
|
96
|
-
Conver string to array of bytes in UTF-8 encoding
|
97
|
-
See:
|
98
|
-
http://www.dangrossman.info/2007/05/25/handling-utf-8-in-javascript-php-and-non-utf8-databases/
|
99
|
-
http://stackoverflow.com/questions/1240408/reading-bytes-from-a-javascript-string
|
100
|
-
How about a String.getBytes(<ENCODING>) for Javascript!? Isn't it time to add it?
|
101
|
-
*/
|
102
|
-
function str_to_bytes(str) {
|
103
|
-
var retval = []
|
104
|
-
for(var i = 0; i < str.length; i++)
|
105
|
-
if(str.charCodeAt(i) <= 0x7F) {
|
106
|
-
retval.push(str.charCodeAt(i))
|
107
|
-
} else {
|
108
|
-
var tmp = encodeURIComponent(str.charAt(i)).substr(1).split('%')
|
109
|
-
for(var j = 0; j < tmp.length; j++) {
|
110
|
-
retval.push(parseInt(tmp[j], 0x10))
|
111
|
-
}
|
112
|
-
}
|
113
|
-
return retval
|
114
|
-
}
|
115
|
-
|
116
|
-
// convert the 4 32-bit buffers to a 128 bit hex string. (Little-endian is assumed)
|
117
|
-
function int128le_to_hex(a, b, c, d) {
|
118
|
-
var ra = ""
|
119
|
-
var t = 0
|
120
|
-
var ta = 0
|
121
|
-
for(var i = 3; i >= 0; i--) {
|
122
|
-
ta = arguments[i]
|
123
|
-
t = (ta & 0xFF)
|
124
|
-
ta = ta >>> 8
|
125
|
-
t = t << 8
|
126
|
-
t = t | (ta & 0xFF)
|
127
|
-
ta = ta >>> 8
|
128
|
-
t = t << 8
|
129
|
-
t = t | (ta & 0xFF)
|
130
|
-
ta = ta >>> 8
|
131
|
-
t = t << 8
|
132
|
-
t = t | ta
|
133
|
-
ra = ra + to_zerofilled_hex(t)
|
134
|
-
}
|
135
|
-
return ra
|
136
|
-
}
|
137
|
-
|
138
|
-
// conversion from typed byte array to plain javascript array
|
139
|
-
function typed_to_plain(tarr) {
|
140
|
-
var retval = new Array(tarr.length)
|
141
|
-
for(var i = 0; i < tarr.length; i++) {
|
142
|
-
retval[i] = tarr[i]
|
143
|
-
}
|
144
|
-
return retval
|
145
|
-
}
|
146
|
-
|
147
|
-
// check input data type and perform conversions if needed
|
148
|
-
var databytes = null
|
149
|
-
// String
|
150
|
-
var type_mismatch = null
|
151
|
-
if( typeof data == 'string') {
|
152
|
-
// convert string to array bytes
|
153
|
-
databytes = str_to_bytes(data)
|
154
|
-
} else if(data.constructor == Array) {
|
155
|
-
if(data.length === 0) {
|
156
|
-
// if it's empty, just assume array of bytes
|
157
|
-
databytes = data
|
158
|
-
} else if( typeof data[0] == 'string') {
|
159
|
-
databytes = chars_to_bytes(data)
|
160
|
-
} else if( typeof data[0] == 'number') {
|
161
|
-
databytes = data
|
162
|
-
} else {
|
163
|
-
type_mismatch = typeof data[0]
|
164
|
-
}
|
165
|
-
} else if( typeof ArrayBuffer != 'undefined') {
|
166
|
-
if( data instanceof ArrayBuffer) {
|
167
|
-
databytes = typed_to_plain(new Uint8Array(data))
|
168
|
-
} else if(( data instanceof Uint8Array) || ( data instanceof Int8Array)) {
|
169
|
-
databytes = typed_to_plain(data)
|
170
|
-
} else if(( data instanceof Uint32Array) || ( data instanceof Int32Array) || ( data instanceof Uint16Array) || ( data instanceof Int16Array) || ( data instanceof Float32Array) || ( data instanceof Float64Array)) {
|
171
|
-
databytes = typed_to_plain(new Uint8Array(data.buffer))
|
172
|
-
} else {
|
173
|
-
type_mismatch = typeof data
|
174
|
-
}
|
175
|
-
} else {
|
176
|
-
type_mismatch = typeof data
|
177
|
-
}
|
178
|
-
|
179
|
-
if(type_mismatch) {
|
180
|
-
alert('MD5 type mismatch, cannot process ' + type_mismatch)
|
181
|
-
}
|
182
|
-
|
183
|
-
function _add(n1, n2) {
|
184
|
-
return 0x0FFFFFFFF & (n1 + n2)
|
185
|
-
}
|
186
|
-
|
187
|
-
return do_digest()
|
188
|
-
|
189
|
-
function do_digest() {
|
190
|
-
|
191
|
-
// function update partial state for each run
|
192
|
-
function updateRun(nf, sin32, dw32, b32) {
|
193
|
-
var temp = d
|
194
|
-
d = c
|
195
|
-
c = b
|
196
|
-
//b = b + rol(a + (nf + (sin32 + dw32)), b32)
|
197
|
-
b = _add(b, rol(_add(a, _add(nf, _add(sin32, dw32))), b32))
|
198
|
-
a = temp
|
199
|
-
}
|
200
|
-
|
201
|
-
// save original length
|
202
|
-
var org_len = databytes.length
|
203
|
-
|
204
|
-
// first append the "1" + 7x "0"
|
205
|
-
databytes.push(0x80)
|
206
|
-
|
207
|
-
// determine required amount of padding
|
208
|
-
var tail = databytes.length % 64
|
209
|
-
// no room for msg length?
|
210
|
-
if(tail > 56) {
|
211
|
-
// pad to next 512 bit block
|
212
|
-
for(var i = 0; i < (64 - tail); i++) {
|
213
|
-
databytes.push(0x0)
|
214
|
-
}
|
215
|
-
tail = databytes.length % 64
|
216
|
-
}
|
217
|
-
for( i = 0; i < (56 - tail); i++) {
|
218
|
-
databytes.push(0x0)
|
219
|
-
}
|
220
|
-
// message length in bits mod 512 should now be 448
|
221
|
-
// append 64 bit, little-endian original msg length (in *bits*!)
|
222
|
-
databytes = databytes.concat(int64_to_bytes(org_len * 8))
|
223
|
-
|
224
|
-
// initialize 4x32 bit state
|
225
|
-
var h0 = 0x67452301
|
226
|
-
var h1 = 0xEFCDAB89
|
227
|
-
var h2 = 0x98BADCFE
|
228
|
-
var h3 = 0x10325476
|
229
|
-
|
230
|
-
// temp buffers
|
231
|
-
var a = 0, b = 0, c = 0, d = 0
|
232
|
-
|
233
|
-
// Digest message
|
234
|
-
for( i = 0; i < databytes.length / 64; i++) {
|
235
|
-
// initialize run
|
236
|
-
a = h0
|
237
|
-
b = h1
|
238
|
-
c = h2
|
239
|
-
d = h3
|
240
|
-
|
241
|
-
var ptr = i * 64
|
242
|
-
|
243
|
-
// do 64 runs
|
244
|
-
updateRun(fF(b, c, d), 0xd76aa478, bytes_to_int32(databytes, ptr), 7)
|
245
|
-
updateRun(fF(b, c, d), 0xe8c7b756, bytes_to_int32(databytes, ptr + 4), 12)
|
246
|
-
updateRun(fF(b, c, d), 0x242070db, bytes_to_int32(databytes, ptr + 8), 17)
|
247
|
-
updateRun(fF(b, c, d), 0xc1bdceee, bytes_to_int32(databytes, ptr + 12), 22)
|
248
|
-
updateRun(fF(b, c, d), 0xf57c0faf, bytes_to_int32(databytes, ptr + 16), 7)
|
249
|
-
updateRun(fF(b, c, d), 0x4787c62a, bytes_to_int32(databytes, ptr + 20), 12)
|
250
|
-
updateRun(fF(b, c, d), 0xa8304613, bytes_to_int32(databytes, ptr + 24), 17)
|
251
|
-
updateRun(fF(b, c, d), 0xfd469501, bytes_to_int32(databytes, ptr + 28), 22)
|
252
|
-
updateRun(fF(b, c, d), 0x698098d8, bytes_to_int32(databytes, ptr + 32), 7)
|
253
|
-
updateRun(fF(b, c, d), 0x8b44f7af, bytes_to_int32(databytes, ptr + 36), 12)
|
254
|
-
updateRun(fF(b, c, d), 0xffff5bb1, bytes_to_int32(databytes, ptr + 40), 17)
|
255
|
-
updateRun(fF(b, c, d), 0x895cd7be, bytes_to_int32(databytes, ptr + 44), 22)
|
256
|
-
updateRun(fF(b, c, d), 0x6b901122, bytes_to_int32(databytes, ptr + 48), 7)
|
257
|
-
updateRun(fF(b, c, d), 0xfd987193, bytes_to_int32(databytes, ptr + 52), 12)
|
258
|
-
updateRun(fF(b, c, d), 0xa679438e, bytes_to_int32(databytes, ptr + 56), 17)
|
259
|
-
updateRun(fF(b, c, d), 0x49b40821, bytes_to_int32(databytes, ptr + 60), 22)
|
260
|
-
updateRun(fG(b, c, d), 0xf61e2562, bytes_to_int32(databytes, ptr + 4), 5)
|
261
|
-
updateRun(fG(b, c, d), 0xc040b340, bytes_to_int32(databytes, ptr + 24), 9)
|
262
|
-
updateRun(fG(b, c, d), 0x265e5a51, bytes_to_int32(databytes, ptr + 44), 14)
|
263
|
-
updateRun(fG(b, c, d), 0xe9b6c7aa, bytes_to_int32(databytes, ptr), 20)
|
264
|
-
updateRun(fG(b, c, d), 0xd62f105d, bytes_to_int32(databytes, ptr + 20), 5)
|
265
|
-
updateRun(fG(b, c, d), 0x2441453, bytes_to_int32(databytes, ptr + 40), 9)
|
266
|
-
updateRun(fG(b, c, d), 0xd8a1e681, bytes_to_int32(databytes, ptr + 60), 14)
|
267
|
-
updateRun(fG(b, c, d), 0xe7d3fbc8, bytes_to_int32(databytes, ptr + 16), 20)
|
268
|
-
updateRun(fG(b, c, d), 0x21e1cde6, bytes_to_int32(databytes, ptr + 36), 5)
|
269
|
-
updateRun(fG(b, c, d), 0xc33707d6, bytes_to_int32(databytes, ptr + 56), 9)
|
270
|
-
updateRun(fG(b, c, d), 0xf4d50d87, bytes_to_int32(databytes, ptr + 12), 14)
|
271
|
-
updateRun(fG(b, c, d), 0x455a14ed, bytes_to_int32(databytes, ptr + 32), 20)
|
272
|
-
updateRun(fG(b, c, d), 0xa9e3e905, bytes_to_int32(databytes, ptr + 52), 5)
|
273
|
-
updateRun(fG(b, c, d), 0xfcefa3f8, bytes_to_int32(databytes, ptr + 8), 9)
|
274
|
-
updateRun(fG(b, c, d), 0x676f02d9, bytes_to_int32(databytes, ptr + 28), 14)
|
275
|
-
updateRun(fG(b, c, d), 0x8d2a4c8a, bytes_to_int32(databytes, ptr + 48), 20)
|
276
|
-
updateRun(fH(b, c, d), 0xfffa3942, bytes_to_int32(databytes, ptr + 20), 4)
|
277
|
-
updateRun(fH(b, c, d), 0x8771f681, bytes_to_int32(databytes, ptr + 32), 11)
|
278
|
-
updateRun(fH(b, c, d), 0x6d9d6122, bytes_to_int32(databytes, ptr + 44), 16)
|
279
|
-
updateRun(fH(b, c, d), 0xfde5380c, bytes_to_int32(databytes, ptr + 56), 23)
|
280
|
-
updateRun(fH(b, c, d), 0xa4beea44, bytes_to_int32(databytes, ptr + 4), 4)
|
281
|
-
updateRun(fH(b, c, d), 0x4bdecfa9, bytes_to_int32(databytes, ptr + 16), 11)
|
282
|
-
updateRun(fH(b, c, d), 0xf6bb4b60, bytes_to_int32(databytes, ptr + 28), 16)
|
283
|
-
updateRun(fH(b, c, d), 0xbebfbc70, bytes_to_int32(databytes, ptr + 40), 23)
|
284
|
-
updateRun(fH(b, c, d), 0x289b7ec6, bytes_to_int32(databytes, ptr + 52), 4)
|
285
|
-
updateRun(fH(b, c, d), 0xeaa127fa, bytes_to_int32(databytes, ptr), 11)
|
286
|
-
updateRun(fH(b, c, d), 0xd4ef3085, bytes_to_int32(databytes, ptr + 12), 16)
|
287
|
-
updateRun(fH(b, c, d), 0x4881d05, bytes_to_int32(databytes, ptr + 24), 23)
|
288
|
-
updateRun(fH(b, c, d), 0xd9d4d039, bytes_to_int32(databytes, ptr + 36), 4)
|
289
|
-
updateRun(fH(b, c, d), 0xe6db99e5, bytes_to_int32(databytes, ptr + 48), 11)
|
290
|
-
updateRun(fH(b, c, d), 0x1fa27cf8, bytes_to_int32(databytes, ptr + 60), 16)
|
291
|
-
updateRun(fH(b, c, d), 0xc4ac5665, bytes_to_int32(databytes, ptr + 8), 23)
|
292
|
-
updateRun(fI(b, c, d), 0xf4292244, bytes_to_int32(databytes, ptr), 6)
|
293
|
-
updateRun(fI(b, c, d), 0x432aff97, bytes_to_int32(databytes, ptr + 28), 10)
|
294
|
-
updateRun(fI(b, c, d), 0xab9423a7, bytes_to_int32(databytes, ptr + 56), 15)
|
295
|
-
updateRun(fI(b, c, d), 0xfc93a039, bytes_to_int32(databytes, ptr + 20), 21)
|
296
|
-
updateRun(fI(b, c, d), 0x655b59c3, bytes_to_int32(databytes, ptr + 48), 6)
|
297
|
-
updateRun(fI(b, c, d), 0x8f0ccc92, bytes_to_int32(databytes, ptr + 12), 10)
|
298
|
-
updateRun(fI(b, c, d), 0xffeff47d, bytes_to_int32(databytes, ptr + 40), 15)
|
299
|
-
updateRun(fI(b, c, d), 0x85845dd1, bytes_to_int32(databytes, ptr + 4), 21)
|
300
|
-
updateRun(fI(b, c, d), 0x6fa87e4f, bytes_to_int32(databytes, ptr + 32), 6)
|
301
|
-
updateRun(fI(b, c, d), 0xfe2ce6e0, bytes_to_int32(databytes, ptr + 60), 10)
|
302
|
-
updateRun(fI(b, c, d), 0xa3014314, bytes_to_int32(databytes, ptr + 24), 15)
|
303
|
-
updateRun(fI(b, c, d), 0x4e0811a1, bytes_to_int32(databytes, ptr + 52), 21)
|
304
|
-
updateRun(fI(b, c, d), 0xf7537e82, bytes_to_int32(databytes, ptr + 16), 6)
|
305
|
-
updateRun(fI(b, c, d), 0xbd3af235, bytes_to_int32(databytes, ptr + 44), 10)
|
306
|
-
updateRun(fI(b, c, d), 0x2ad7d2bb, bytes_to_int32(databytes, ptr + 8), 15)
|
307
|
-
updateRun(fI(b, c, d), 0xeb86d391, bytes_to_int32(databytes, ptr + 36), 21)
|
308
|
-
|
309
|
-
// update buffers
|
310
|
-
h0 = _add(h0, a)
|
311
|
-
h1 = _add(h1, b)
|
312
|
-
h2 = _add(h2, c)
|
313
|
-
h3 = _add(h3, d)
|
314
|
-
}
|
315
|
-
// Done! Convert buffers to 128 bit (LE)
|
316
|
-
return int128le_to_hex(h3, h2, h1, h0)
|
317
|
-
}
|
318
|
-
|
319
|
-
};
|