Cphalcon: [BUG-V4]: Missing numbers and letters in Helper\Str::random

Created on 16 Dec 2019  路  4Comments  路  Source: phalcon/cphalcon

In the random function of the class HelperStr :
https://github.com/phalcon/cphalcon/blob/6f063edc1b0f1f058724863d71a397564afa7353/phalcon/Helper/Str.zep#L557

Why the number 1 and letters B, G, I, O, Q are not in the case RANDOM_DISTINCT ?
If I'm right, it's not better to use:

let pool = array_merge(
                    range(0, 9),
                    range("A", "Z")
                );

And I don't understand what RANDOM_DISTINCT does ?
Thanks for your help

bug unverified

All 4 comments

I believe it was done for readability. 0 looks very similar to O for instance.

The RANDOM_DISTINCT will generate a string that does not have repeating characters in it.

@niden It's clearer about the letters and numbers missing.
But when I used the function random with the constant RANDOM_DISTINCT.
I had results like that:
U24JAJA5
or
533RTC6D

@jenovateurs I think the method is used to only generate a list of distincted numbers and letters that lookalike. Maybe distinct is not the best word in this case because it's completely removing both. The amount of characters looks a bit too small to have a good distinct use case. It could use some docs love. Thnx for reporting.

@ruudboon Thanks for the additionnal information.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TimurFlush picture TimurFlush  路  3Comments

EquaI1ty picture EquaI1ty  路  3Comments

fonqing picture fonqing  路  3Comments

dimak08 picture dimak08  路  3Comments

borisdelev picture borisdelev  路  3Comments