mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
crypto: Pass encodings for Hmac digest
This commit is contained in:
parent
c1e8c8de1c
commit
a241deb19a
@ -213,10 +213,7 @@ Hash.prototype.update = function(data, encoding) {
|
||||
|
||||
Hash.prototype.digest = function(outputEncoding) {
|
||||
outputEncoding = outputEncoding || exports.DEFAULT_ENCODING;
|
||||
var ret = this._binding.digest(outputEncoding);
|
||||
if (outputEncoding !== 'buffer' && Buffer.isBuffer(ret))
|
||||
ret = ret.toString(outputEncoding);
|
||||
return ret;
|
||||
return this._binding.digest(outputEncoding);
|
||||
};
|
||||
|
||||
|
||||
|
@ -2761,6 +2761,11 @@ class Hmac : public ObjectWrap {
|
||||
|
||||
HandleScope scope;
|
||||
|
||||
enum encoding encoding = BUFFER;
|
||||
if (args.Length() >= 1) {
|
||||
encoding = ParseEncoding(args[0]->ToString(), BUFFER);
|
||||
}
|
||||
|
||||
unsigned char* md_value = NULL;
|
||||
unsigned int md_len = 0;
|
||||
Local<Value> outString;
|
||||
@ -2771,9 +2776,10 @@ class Hmac : public ObjectWrap {
|
||||
md_len = 0;
|
||||
}
|
||||
|
||||
outString = Encode(md_value, md_len, BUFFER);
|
||||
outString = StringBytes::Encode(
|
||||
reinterpret_cast<const char*>(md_value), md_len, encoding);
|
||||
|
||||
delete [] md_value;
|
||||
delete[] md_value;
|
||||
return scope.Close(outString);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user