Hash.RandomString
-----------------

Creates a random string.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Hash](component_Hash.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Hash.RandomString"; Length { ; Characters } ) 

**MBS**( **"Hash.RandomString";** /\* Creates a random string. \*/  
**$Length**; /\* The length of the text to return in characters.e.g. 32 \*/   
**$Characters**) /\* Optional; Optional, a list of characters to use instead of default set.e.g. "1234" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Length | The length of the text to return in characters. | 32 |  |
| Characters | Optional, a list of characters to use instead of default set. | "1234" | Optional |

### Result

Returns text.

### Description

Creates a random string.  
User Characters: a to z, A to Z and 0 to 9.  
You can use this strings for hash seeds or as password suggestions.  
### Examples

Creates 8 byte string:

 MBS ( "Hash.RandomString"; 8 )  
Create random text with only digits:

 MBS ("Hash.RandomString"; 32; "1234567890")  
Create random hex number:

 MBS ("Hash.RandomString"; 32; "")  
Create random password using digits and punctuation:

 MBS ("Hash.RandomString"; 10; "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&amp;\*-\_+=.")  
### See also

- [Hash.RandomHexString](HashRandomHexString.md)

### Release notes

- **Version 8.3**
    - Improved randomness for [Hash.RandomString](http://www.mbsplugins.eu/HashRandomString.shtml) function.

### Example Databases

- [CURL/WebServices/Twitter oAuth](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/Twitter%20oAuth.shtml#5ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 8.3pr5](https://www.mbsplugins.de/archive/2018-07-10/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 3.2pr7](https://www.mbsplugins.de/archive/2013-04-16/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 11st June 2026

  
[Hash.RandomHexString](HashRandomHexString.md) - [Hash.SHA1](HashSHA1.md)

[HTML Version](HashRandomString.shtml)