프로젝트

일반

사용자정보

통계
| 개정판:

root / HServer / 00.Server / 00.Program / node_modules / uid-safe / README.md

이력 | 보기 | 이력해설 | 다운로드 (2.11 KB)

1
# uid-safe
2

    
3
[![NPM Version][npm-image]][npm-url]
4
[![NPM Downloads][downloads-image]][downloads-url]
5
[![Node.js Version][node-version-image]][node-version-url]
6
[![Build Status][travis-image]][travis-url]
7
[![Test Coverage][coveralls-image]][coveralls-url]
8

    
9
URL and cookie safe UIDs
10

    
11
Create cryptographically secure UIDs safe for both cookie and URL usage.
12
This is in contrast to modules such as [rand-token](https://www.npmjs.com/package/rand-token)
13
and [uid2](https://www.npmjs.com/package/uid2) whose UIDs are actually skewed
14
due to the use of `%` and unnecessarily truncate the UID.
15
Use this if you could still use UIDs with `-` and `_` in them.
16

    
17
## Installation
18

    
19
```sh
20
$ npm install uid-safe
21
```
22

    
23
## API
24

    
25
```js
26
var uid = require('uid-safe')
27
```
28

    
29
### uid(byteLength, callback)
30

    
31
Asynchronously create a UID with a specific byte length. Because `base64`
32
encoding is used underneath, this is not the string length. For example,
33
to create a UID of length 24, you want a byte length of 18.
34

    
35
```js
36
uid(18, function (err, string) {
37
  if (err) throw err
38
  // do something with the string
39
})
40
```
41

    
42
### uid(byteLength)
43

    
44
Asynchronously create a UID with a specific byte length and return a
45
`Promise`.
46

    
47
**Note**: To use promises in Node.js _prior to 0.12_, promises must be
48
"polyfilled" using `global.Promise = require('bluebird')`.
49

    
50
```js
51
uid(18).then(function (string) {
52
  // do something with the string
53
})
54
```
55

    
56
### uid.sync(byteLength)
57

    
58
A synchronous version of above.
59

    
60
```js
61
var string = uid.sync(18)
62
```
63

    
64
## License
65

    
66
[MIT](LICENSE)
67

    
68
[npm-image]: https://img.shields.io/npm/v/uid-safe.svg
69
[npm-url]: https://npmjs.org/package/uid-safe
70
[node-version-image]: https://img.shields.io/node/v/uid-safe.svg
71
[node-version-url]: https://nodejs.org/en/download/
72
[travis-image]: https://img.shields.io/travis/crypto-utils/uid-safe/master.svg
73
[travis-url]: https://travis-ci.org/crypto-utils/uid-safe
74
[coveralls-image]: https://img.shields.io/coveralls/crypto-utils/uid-safe/master.svg
75
[coveralls-url]: https://coveralls.io/r/crypto-utils/uid-safe?branch=master
76
[downloads-image]: https://img.shields.io/npm/dm/uid-safe.svg
77
[downloads-url]: https://npmjs.org/package/uid-safe