Skip to content

Commit

Permalink
All numbers to be hashed
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Oct 4, 2011
1 parent 60022ce commit b0f4de1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Client.coffee
Expand Up @@ -27,4 +27,5 @@ module.exports = class Client
callback null, status if callback

hash: (key) ->
key = "#{key}" if typeof key is 'number'
return if key? then crypto.createHash('sha1').update(key).digest('hex') else 'null'
19 changes: 19 additions & 0 deletions test/Client.coffee
@@ -0,0 +1,19 @@

assert = require 'assert'

config = require '../conf/test'
Ron = require '../index'

ron = Ron config

module.exports =
'init': (exit) ->
exit()
'Test hash # with string': (exit) ->
assert.eql ron.hash('1'), '356a192b7913b04c54574d18c28d46e6395428ab'
exit()
'Test hash # with number': (exit) ->
assert.eql ron.hash(1), '356a192b7913b04c54574d18c28d46e6395428ab'
exit()
'destroy': (exit) ->
ron.quit exit

0 comments on commit b0f4de1

Please sign in to comment.