Total Complexity | 9 |
Complexity/F | 1.5 |
Lines of Code | 44 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /** global: aesCrypt */ |
||
20 | (function () { |
||
21 | let LIB = aesCrypt; |
||
|
|||
22 | aesCrypt.BinaryStream = function(arr = []) { |
||
23 | let _data = new Uint8Array(arr); |
||
24 | |||
25 | function appendBytes(input) { |
||
26 | let tmp = []; |
||
27 | |||
28 | if (typeof (input) == "number") { |
||
29 | let hex = input.toString(16); |
||
30 | tmp = hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)); |
||
31 | } else if (typeof (input) == "string") { |
||
32 | for (let i = 0; i < input.length; i ++) { |
||
33 | tmp.push(input.charCodeAt(i)); |
||
34 | } |
||
35 | } else { |
||
36 | tmp = input; |
||
37 | } |
||
38 | |||
39 | tmp = new Uint8Array(tmp); |
||
40 | |||
41 | let tmpArr = new Uint8Array(_data.length + tmp.length); |
||
42 | |||
43 | tmpArr.set(_data); |
||
44 | tmpArr.set(tmp, _data.length); |
||
45 | |||
46 | _data = tmpArr; |
||
47 | } |
||
48 | |||
49 | function finalize() { |
||
50 | return _data; |
||
51 | } |
||
52 | |||
53 | function getLength() { |
||
54 | return _data.length; |
||
55 | } |
||
56 | |||
57 | return { |
||
58 | appendBytes, |
||
59 | finalize, |
||
60 | getLength, |
||
61 | } |
||
62 | }; |
||
63 | }()); |