Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
node-cipher-base
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Debian JavaScript Maintainers
node-cipher-base
Commits
61491fe3
Commit
61491fe3
authored
Sep 26, 2015
by
Calvin Metcalf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error in 0.10
parent
8fbd9e76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
index.js
index.js
+6
-2
test.js
test.js
+25
-0
No files found.
index.js
View file @
61491fe3
...
...
@@ -5,7 +5,7 @@ module.exports = CipherBase
inherits
(
CipherBase
,
Transform
)
function
CipherBase
(
hashMode
)
{
Transform
.
call
(
this
)
this
.
hashMode
=
typeof
hashMode
===
'
string
'
;
this
.
hashMode
=
typeof
hashMode
===
'
string
'
if
(
this
.
hashMode
)
{
this
[
hashMode
]
=
this
.
_finalOrDigest
}
else
{
...
...
@@ -30,7 +30,11 @@ CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
CipherBase
.
prototype
.
_transform
=
function
(
data
,
_
,
next
)
{
var
err
try
{
this
.
push
(
this
.
_update
(
data
))
if
(
this
.
hashMode
)
{
this
.
_update
(
data
)
}
else
{
this
.
push
(
this
.
_update
(
data
))
}
}
catch
(
e
)
{
err
=
e
}
finally
{
...
...
test.js
View file @
61491fe3
...
...
@@ -42,6 +42,31 @@ test('hash mode', function (t) {
t
.
equals
(
utf8
,
string
)
t
.
end
()
})
test
(
'
hash mode as stream
'
,
function
(
t
)
{
inherits
(
Cipher
,
CipherBase
)
function
Cipher
()
{
CipherBase
.
call
(
this
,
'
finalName
'
)
this
.
_cache
=
[]
}
Cipher
.
prototype
.
_update
=
function
(
input
)
{
t
.
ok
(
Buffer
.
isBuffer
(
input
))
this
.
_cache
.
push
(
input
)
}
Cipher
.
prototype
.
_final
=
function
()
{
return
Buffer
.
concat
(
this
.
_cache
)
}
var
cipher
=
new
Cipher
()
cipher
.
on
(
'
error
'
,
function
(
e
)
{
t
.
notOk
(
e
)
})
var
utf8
=
'
abc123abcd
'
cipher
.
end
(
utf8
,
'
utf8
'
)
var
update
=
cipher
.
read
().
toString
(
'
base64
'
)
var
string
=
(
new
Buffer
(
update
,
'
base64
'
)).
toString
()
t
.
equals
(
utf8
,
string
)
t
.
end
()
})
test
(
'
encodings
'
,
function
(
t
)
{
inherits
(
Cipher
,
CipherBase
)
function
Cipher
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment