Pipe - Text Function to Generate Random Text

If this exists I can’t find it :slight_smile: so I thought I’d drop it here for feedback…perhaps I’ve missed something :thinking:

I need to create a random string of characters from a reduced set of characters. For argument sake lets say I want to limit the characters to “12345QWERTY”

So I know I could create a TB Javaside script called from a Pipe and I’m probably going down that route but it would be nice if this was a was on API calls included in the Tadabase Text Utilities pipe. There is already something similar the “Password Phase Generator” which creates a random phrase but this would be a little different.

There could be two parameter:
Length of String = 10
Available characters = 12345QWERTY

Result Example: 44W21TR42Q

This would be really useful for generating pins for SMS resets, passwords and in my case just a long random filename for AWS file storage.

[I’m currently performing this function in MAKE but it’s really inefficient as it users 40+ “operations” (and this is their suggested method!)]

I created this pipe if anyone else finds it useful it’s here, works well for me :slight_smile:

newstring =“”;
for (let i = 1; i <= {length}; i++) {
randnum = Math.floor(Math.random() * “{characters}”.length);
newchar = “{characters}”.substring(randnum ,randnum +1);
newstring =newstring+newchar
}



1 Like