# Functions ## randomAsHex ▸ **randomAsHex**(length?: *`number`*): `string` *Defined in [random/asHex.ts:23](https://github.com/polkadot-js/common/blob/dc0563d/packages/util-crypto/src/random/asHex.ts#L23)* *__name__*: randomAsHex *__summary__*: Creates a hex string filled with random bytes. *__description__*: Returns a hex string with the specified (optional) length filled with random bytes. *__example__*: ```javascript import { randomAsHex } from '@polkadot/util-crypto'; randomAsHex(); // => 0x... ``` **Parameters:** | Name | Type | Default value | | ------ | ------ | ------ | | `Default value` length | `number` | 32 | **Returns:** `string` ___