Skip to content

Instantly share code, notes, and snippets.

Last active September 27, 2017 07:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save craigedmonds/61ff76a38946519f39b070a52be69f9f to your computer and use it in GitHub Desktop.
Create a complex login password for rackspace mail api
Create a complex 8 character password which meets (exceeds actually) the rackspace mail requirements.
Author: ON 27/9/2017
This function allows you to specify the length of the password and the specific characters to include in the password.
Compleletly random passwords look ugly, so this function will build the password into a random and complex, yet friendlier looking password.
EG: Man$6256 or Lin%9082
This is expecially useful if you need to give the password to a client over the phone or read the password out.
You can meet ALL the following requirements with this function:
At least 8 characters long
One lowercase character
One uppercase character
One number
One non-alphanumeric character (!, $, #, %, etc)
NO sequential numbers (EG: 123 or 456 or 789 etc)
NOTE: passwords should always be as long as possible, not just 8 chars! But this password is a starting pinit for clients.
function create_rackspace_mail_email_password() {
//generate the first part of the password for the user
//to avoid readibility issues for end users, avoid using 0,i,l
$length = 4;
$chars = "abcdefghjkmnpqrstuvwxyz";
$first_part = substr(str_shuffle($chars),0,$length);
//generate the second part of the password for the user
//add more non-alphanumeric characters to $chars if you want
//I suggest only adding the more common ones as on mobile
//and foreign keyboards its sometimes hard to find the symbols.
$length = 1;
$chars = "$#%!";
$second_part = substr(str_shuffle($chars),0,$length);
//generate the third part of the password for the user
//to avoid sequential numbers, use: 02468 for $chars
$length = 3;
$chars = "02468";
$third_part = substr(str_shuffle($chars),0,$length);
//join all togther to form password and capitalise the first letter
return ucfirst($first_part . $second_part. $third_part);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment