I'm looking for an efficient way to build a random string that has specific requirements but can vary in length. It must:
- Contain at least one uppercase character.
- Contain at least one lowercase character.
- Contain at least one number.
- Contain at least one of the special characters: _-|@.,?/!~#$%^&*(){}[]+=
The random string doesn't have to be unique but if it is, its better. It will be used in a node.js server so any crypto library can be made use of. I saw Math.random().toString(36)
which comes close but doesn't get me everything. I'm not sure if I should just try to build a regex for this.