Re: using CRYPT but restrict alpha-numeric
| From: | AllenJB | Date: | Wed, 08 Dec 2021 08:56:43 +0000 |
| Subject: | Re: using CRYPT but restrict alpha-numeric | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327863@lists.php.net to get a copy of this message | ||
On 07/12/2021 23:11, gordonisnz@gmail.com wrote:
Hello. I'm looking at the various CRYPT / one-way encryption commands and i was wondering if there is a way to create a crypt but restrict output to alpha-numeric (a to z, A to Z and 0-9) without the special characters ? Basically ive got a starting reference - numeric over 10,000,000 and other numbers and want to do a crypt (or something) but exclude special characters from the crypt result. The best I can think of is to do a crypt (or whatever) etc and then do a preg_replace to remove the special characters etc.. The result will be shorter (length), but will be an alpha-numeric crypt. -- Gordon.What problem are you trying to solve by doing this?
crypt on its own doesn't tell us much as it's a library that can use multiple algorithms.
It should be noted that (password) hashing algorithms already use a restricted character set that is basically alphanumeric plus a few other characters. The current defacto standard for password hashes is the modular crypt format which you can see explained on the Description and Version History sections of https://en.wikipedia.org/wiki/Bcrypt and the Radix-64 character set used is described on https://en.wikipedia.org/wiki/Base64#Radix-64_applications_not_compatible_with_Base64