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);
};
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;
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);
}