Skip to content

Commit 55d4128

Browse files
committed
Read buffer data in a browser-compatible way
1 parent 5b77927 commit 55d4128

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/util.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ AWS.util = {
228228
}
229229

230230
for (var i = 0; i < data.length; i++) {
231-
crc = (crc>>>8) ^ tbl[(crc^data[i])&0xFF];
231+
var code = data.readUInt8(i);
232+
crc = (crc>>>8) ^ tbl[(crc^code)&0xFF];
232233
}
233234
return (crc ^ -1) >>> 0;
234235
},

test/util.spec.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe 'AWS.util.crypto', ->
135135
it 'returns the correct CRC32 value for binary data', ->
136136
buffer = new Buffer(4433);
137137
for i in [0...buffer.length]
138-
buffer[i] = i % 256;
138+
buffer.writeUInt8 i % 256, i
139139
expect(util.crc32(buffer)).toEqual(899332870)
140140

141141
it 'handles String values', ->

0 commit comments

Comments
 (0)