0.0.2 • Published 6 years ago

n-utility v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

n-utility

a collection of normal utility

install

  npm install n-utility

Usage

  const util = require('n-utility')

md5

  util.md5("nian")  // "d5e1c22f261c7dd151448e6b86fac8bf"
  util.md5("nian", "base64") //

sha1

  util.sha1("nian") // "22683fb1d93c5d687e941e3d74ff0db0477aae54"

sha256

  util.sha256("nian") //"9850fdca22f422d915e2f282285378719ecea4770c7206b6cc37cd9e3d4968f3"

encode and decode

  // base64encode 
  util.base64encode("你好 hello world") // 5L2g5aW9IGhlbGxvIHdvcmxk
  // base64decode
  util.base64decode("5L2g5aW9IGhlbGxvIHdvcmxk") //你好 hello world

randomString

  util.randomString() // a 16 length random string
  util.randomString(10, [0, 1, 2, 3, 4, 5]) // a 10 length random string and char in [0, 1, 2, 3, 4, 5]

random

  util.random(15) // a random number between 0 and 15
  util.random(-20, 100) // a random number between -20 and 100

reference

utility

License

MIT