<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) &gt; [randomString](./brick-next-pipes.randomstring.md)

## randomString() function

获得一个随机字符串

 Others

**Signature:**

```typescript
export declare function randomString(length?: number, characters?: string): string;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  length | number | 随机字符串的长度，默认为8。 |
|  characters | string | 随机字符串包含哪些字符，默认为大小写字母及数字。例如指定"0123456789"则随机字符只会包含数字；指定"0123456789abcdef"则随机字符是个16进制数。 |

**Returns:**

string

随机字符串

## Example


```ts
randomString()
// Returns "jUf92Zd0".

randomString(6)
// Returns "sUf0Zd".

randomString(6, "0123456789@")
// Returns "971@12".
```


