> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/js/all/node/packages/crypto.md).

# Crypto

### Generate Random String

```javascript
var crypto = require("crypto");
var id = crypto.randomBytes(24).toString('hex'); //byte to hex doubles length, so this will be length 40
```

## Nanoid

<https://github.com/ai/nanoid>

```javascript
const nanoid = require('nanoid')
model.id = nanoid()//=> "V1StGXR8_Z5jdHi6B-myT"
nanoid(10) //=> "IRFa-VaY2b"
```
