Skip to content
Permalink
Browse files

hash, feat: use Buffer to encode the result of digest.

  • Loading branch information...
xicilion committed Oct 3, 2018
1 parent bee235f commit 02b2cba9cc3405d52fa63df6e41e5091567ffe52
Showing with 5 additions and 6 deletions.
  1. +5 −6 fibjs/src/crypto/Digest.cpp
@@ -59,8 +59,7 @@ result_t Digest::update(Buffer_base* data, obj_ptr<Digest_base>& retVal)
return 0;
}

result_t Digest::digest(exlib::string codec,
v8::Local<v8::Value>& retVal)
result_t Digest::digest(exlib::string codec, v8::Local<v8::Value>& retVal)
{
exlib::string strBuf;
if (m_iAlgo < 0)
@@ -76,12 +75,12 @@ result_t Digest::digest(exlib::string codec,
m_iAlgo = -1;
mbedtls_md_hmac_reset(&m_ctx);

if ((codec == "buffer")) {
obj_ptr<Buffer_base> buf = new Buffer(strBuf);
obj_ptr<Buffer_base> buf = new Buffer(strBuf);
if ((codec == "buffer"))
retVal = buf->wrap();
} else {
else {
exlib::string data;
result_t hr = commonEncode(codec, strBuf, data);
result_t hr = buf->toString(codec, 0, data);
if (hr < 0)
return hr;

0 comments on commit 02b2cba

Please sign in to comment.
You can’t perform that action at this time.