Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
50c1875f
authored
2016-02-02 17:50:29 -0500
by
brandonocasey
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
code review fixes
1 parent
3c428e4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
31 deletions
src/decrypter.js
test/decrypter.test.js
src/decrypter.js
View file @
50c1875
...
...
@@ -101,7 +101,7 @@ const precompute = function() {
decTable
[
i
]
=
decTable
[
i
].
slice
(
0
);
}
return
_tables
;
}
}
;
let
tables
;
...
...
@@ -367,12 +367,11 @@ export class AsyncStream extends Stream {
}
// the maximum number of bytes to process at one time
const
d
ecrypterStep
=
4
*
8000
;
const
D
ecrypterStep
=
4
*
8000
;
export
class
Decrypter
extends
Stream
{
export
class
Decrypter
{
constructor
(
encrypted
,
key
,
initVector
,
done
)
{
super
(
Stream
);
let
step
=
decrypterStep
;
let
step
=
DecrypterStep
;
let
encrypted32
=
new
Int32Array
(
encrypted
.
buffer
);
let
decrypted
=
new
Uint8Array
(
encrypted
.
byteLength
);
let
i
=
0
;
...
...
@@ -409,7 +408,7 @@ export class Decrypter extends Stream {
}
}
Decrypter
.
STEP
=
d
ecrypterStep
;
Decrypter
.
STEP
=
D
ecrypterStep
;
export
default
{
decrypt
,
...
...
test/decrypter.test.js
View file @
50c1875
...
...
@@ -106,24 +106,20 @@ QUnit.test('asynchronously decrypts a 4-word block', function() {
let
key
=
new
Uint32Array
([
0
,
0
,
0
,
0
]);
let
initVector
=
key
;
// the string "howdy folks" encrypted
let
encrypted
=
new
Uint8Array
([
0xce
,
0x90
,
0x97
,
0xd0
,
0x08
,
0x46
,
0x4d
,
0x18
,
0x4f
,
0xae
,
0x01
,
0x1c
,
0x82
,
0xa8
,
0xf0
,
0x67
]);
let
encrypted
=
new
Uint8Array
([
0xce
,
0x90
,
0x97
,
0xd0
,
0x08
,
0x46
,
0x4d
,
0x18
,
0x4f
,
0xae
,
0x01
,
0x1c
,
0x82
,
0xa8
,
0xf0
,
0x67
]);
let
decrypted
;
let
decrypter
=
new
Decrypter
(
encrypted
,
key
,
initVector
,
function
(
error
,
result
)
{
if
(
error
)
{
throw
new
Error
(
error
);
}
decrypted
=
result
;
}
);
let
decrypter
=
new
Decrypter
(
encrypted
,
key
,
initVector
,
function
(
error
,
result
)
{
if
(
error
)
{
throw
new
Error
(
error
);
}
decrypted
=
result
;
});
QUnit
.
ok
(
!
decrypted
,
'asynchronously decrypts'
);
this
.
clock
.
tick
(
decrypter
.
asyncStream_
.
delay
*
2
);
...
...
@@ -137,14 +133,12 @@ QUnit.test('asynchronously decrypts a 4-word block', function() {
QUnit
.
test
(
'breaks up input greater than the step value'
,
function
()
{
let
encrypted
=
new
Int32Array
(
Decrypter
.
STEP
+
4
);
let
done
=
false
;
let
decrypter
=
new
Decrypter
(
encrypted
,
new
Uint32Array
(
4
),
new
Uint32Array
(
4
),
function
()
{
done
=
true
;
}
);
let
decrypter
=
new
Decrypter
(
encrypted
,
new
Uint32Array
(
4
),
new
Uint32Array
(
4
),
function
()
{
done
=
true
;
});
this
.
clock
.
tick
(
decrypter
.
asyncStream_
.
delay
*
2
);
QUnit
.
ok
(
!
done
,
'not finished after two ticks'
);
...
...
Please
register
or
sign in
to post a comment