FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bitcore/test/test.SecureRandom.js at master · jonasbits/bitcore · GitHub
jonasbits
/
bitcore
Public
forked from
bitpay/bitcore
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
bitcore
/
test
/
test.SecureRandom.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (51 loc) · 1.98 KB
Breadcrumbs
bitcore
/
test
/
test.SecureRandom.js
Copy path
File metadata and controls
66 lines (51 loc) · 1.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict'
;
var
chai
=
chai
||
require
(
'chai'
)
;
var
bitcore
=
bitcore
||
require
(
'../bitcore'
)
;
var
should
=
chai
.
should
(
)
;
var
assert
=
chai
.
assert
;
var
SecureRandom
=
bitcore
.
SecureRandom
;
describe
(
'SecureRandom'
,
function
(
)
{
describe
(
'getRandomBuffer'
,
function
(
)
{
it
(
'should return a buffer'
,
function
(
)
{
var
bytes
=
SecureRandom
.
getRandomBuffer
(
8
)
;
bytes
.
length
.
should
.
equal
(
8
)
;
Buffer
.
isBuffer
(
bytes
)
.
should
.
equal
(
true
)
;
}
)
;
it
(
'should not equate two 256 bit random buffers'
,
function
(
)
{
var
bytes1
=
SecureRandom
.
getRandomBuffer
(
32
)
;
var
bytes2
=
SecureRandom
.
getRandomBuffer
(
32
)
;
bytes1
.
toString
(
'hex'
)
.
should
.
not
.
equal
(
bytes2
.
toString
(
'hex'
)
)
;
}
)
;
it
(
'should generate 1000 8 byte buffers in a row that are not equal'
,
function
(
)
{
var
bufs
=
[
]
;
for
(
var
i
=
0
;
i
<
100
;
i
++
)
bufs
[
i
]
=
SecureRandom
.
getRandomBuffer
(
8
)
;
for
(
var
i
=
0
;
i
<
100
;
i
++
)
for
(
var
j
=
i
+
1
;
j
<
100
;
j
++
)
bufs
[
i
]
.
toString
(
'hex'
)
.
should
.
not
.
equal
(
bufs
[
j
]
.
toString
(
'hex'
)
)
;
}
)
;
}
)
;
describe
(
'getPseudoRandomBuffer'
,
function
(
)
{
it
(
'should generate 7 random bytes'
,
function
(
)
{
var
buf
=
SecureRandom
.
getPseudoRandomBuffer
(
7
)
;
buf
.
length
.
should
.
equal
(
7
)
;
}
)
;
it
(
'should generate 8 random bytes'
,
function
(
)
{
var
buf
=
SecureRandom
.
getPseudoRandomBuffer
(
8
)
;
buf
.
length
.
should
.
equal
(
8
)
;
}
)
;
it
(
'should generate 9 random bytes'
,
function
(
)
{
var
buf
=
SecureRandom
.
getPseudoRandomBuffer
(
9
)
;
buf
.
length
.
should
.
equal
(
9
)
;
}
)
;
it
(
'should generate 90 random bytes'
,
function
(
)
{
var
buf
=
SecureRandom
.
getPseudoRandomBuffer
(
90
)
;
buf
.
length
.
should
.
equal
(
90
)
;
}
)
;
it
(
'should generate two 8 byte buffers that are not equal'
,
function
(
)
{
var
buf1
=
SecureRandom
.
getPseudoRandomBuffer
(
8
)
;
var
buf2
=
SecureRandom
.
getPseudoRandomBuffer
(
8
)
;
buf1
.
toString
(
'hex'
)
.
should
.
not
.
equal
(
buf2
.
toString
(
'hex'
)
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL