Generating Random Passwords 4 – Emoji

In Generating Random Passwords 3 – Untypable Characters we experimented with generating characters that are not on our keyboard. We can take that another step and use emoji characters.

To handle this, I’m going to use another library that has emoji loaded in it already. I’ll add this to my composer.json, and then run composer update.

This library has a dictionary of emoji, and a converter to be able to output them to HTML or the console. Some of these do not print correctly in the console, especially if you have a monochromatic font on your console, and 99% of us do.

Let’s add the dictionary. This is long, so if you want to see it, you will need to take a look on GitHub , GitLab , or Our GitLab .

I’ve commented out the color variations and the flags, as they were not rendering correctly.

And the function that will make use of that dictionary.

Here I am taking the base pool, and adding the emoji character to it.

Now we will add the flag, --e to the application.

Alright, now let’s run that and see what happens!

This is on Windows 7, PHP 7.0.

Okay, better than I was expecting, to be honest.

This is on Windows 8.1, PHP 7.1

This is really strange. In the console, I get a bunch of squares, as if it did not render correctly. But when I copy it to the blog, it works, almost. The number of characters is not 32, like I had requested of the program.

This is Ubuntu 17.04, PHP 7.1

In the console, none of the emoji have color; I touched on that at the beginning of this post. But we have 32 characters, and they render in the console. We do have a winner.

The repository for this post can be found on GitHub here .

The repository for this post can be found on GitLab here .

The repository for this post can be found on Lupe Code’s GitLab mirror here .