Re: [nodejs] Crypto Error - TypeError: Not a string or buffer

2,810 views
Skip to first unread message

Ruben LZ Tan

unread,
Dec 14, 2012, 4:52:32 AM12/14/12
to nod...@googlegroups.com
It works for me in node REPL. Node v0.8.11, OSX lion 10.7.5

Thanks,
Ruben Tan

On Friday, December 14, 2012 at 9:21 AM, Arunprabu Durairaju wrote:

I am trying to use crypt in my code to hash the password and getting the following error. I have given the code in the bottom of this post. I am using node version 0.8.16 on osx Lion 10.7.5.

I tried searching for the issue and found couple of similar posts but happening only on specific modules and they were old.
 
crypto.js:138
  return (new Hmac).init(hmac, key);
                    ^
TypeError: Not a string or buffer
    at Object.exports.createHmac (crypto.js:138:21)
    at addAdmin (/Users/apps//data_processor.js:37:26)

Here is my code:
    
var hashedpass = crypto.createHmac("sha1", password).update('salttext').digest("hex");

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Ben Noordhuis

unread,
Dec 14, 2012, 4:54:19 AM12/14/12
to nod...@googlegroups.com
On Fri, Dec 14, 2012 at 2:21 AM, Arunprabu Durairaju
<arun...@gmail.com> wrote:
> I am trying to use crypt in my code to hash the password and getting the
> following error. I have given the code in the bottom of this post. I am
> using node version 0.8.16 on osx Lion 10.7.5.
>
> I tried searching for the issue and found couple of similar posts but
> happening only on specific modules and they were old.
>
> crypto.js:138
> return (new Hmac).init(hmac, key);
> ^
> TypeError: Not a string or buffer
> at Object.exports.createHmac (crypto.js:138:21)
> at addAdmin (/Users/apps//data_processor.js:37:26)
>
> Here is my code:
>
> var hashedpass = crypto.createHmac("sha1",
> password).update('salttext').digest("hex");

The error message suggests `password` is neither a string or a buffer.
Reply all
Reply to author
Forward
0 new messages