Ooh, you have a library that generates text to match regexes? I’d be interested to see it! That’s something I’ve actually had a need for. Hypothesis has something like that for property-based testing, but I couldn’t make use of it in the context I needed it.
I do, and people do seem to use it for testing (hilariously not a use case I’d initially considered when writing it), but I’m pretty lax about maintaining it. The dependencies I (today) noticed are quite out of date and non-trivial to update. If you’d like to check it out, it’s here: https://crates.io/crates/regex_generate/0.2.3
If you’d like a more updated version, there are a few forks but also someone seems to have taken the concept and run a little farther with it: https://crates.io/crates/rand_regex
That one seems more explicitly for testing and might be suitable to your needs. These are both Rust crates but should be usable from any language with a C compatible FFI.
I should add this as a default option in my “reverse”-regex text generator library. It’d be neat to have a cli tool for generating random passwords.
(Please respond with your favorite bash/python/powershell one liner for doing this.)
I use this when I don’t have Bitwarden generator available:
openssl rand -base64 64
tr -d '\n' < /dev/random | head -c256 | LANG=C sed 's/[^\x21-\x7E]//g' | head -c3
If you can figure out how to make
sed
stop after it outputs a specific number of characters, thehead -c256
can be dropped.Ooh, you have a library that generates text to match regexes? I’d be interested to see it! That’s something I’ve actually had a need for. Hypothesis has something like that for property-based testing, but I couldn’t make use of it in the context I needed it.
I do, and people do seem to use it for testing (hilariously not a use case I’d initially considered when writing it), but I’m pretty lax about maintaining it. The dependencies I (today) noticed are quite out of date and non-trivial to update. If you’d like to check it out, it’s here: https://crates.io/crates/regex_generate/0.2.3
If you’d like a more updated version, there are a few forks but also someone seems to have taken the concept and run a little farther with it: https://crates.io/crates/rand_regex
That one seems more explicitly for testing and might be suitable to your needs. These are both Rust crates but should be usable from any language with a C compatible FFI.