Description:
1, the password altogether 8 bits.
2, by 2 digits, 2 uppercase characters, 2 lowercase characters, 2 special characters.
3, the sequence of characters is composed of random.
Copy Code code as follows:
function Createpassword
{
$figure =1,2,3,4,5,6,7,8,9;
$capital = "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", " M ";
$lowercase = "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "a", "s", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N" , "M";
$specialCharacter = "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "+";
$order =new-object System.Collections.ArrayList;
for ($i =0; $i-lt 8; $i + +)
{
[void] $order. ADD ($i);
}
$newOrder =@ ();
for ($i =0; $i-lt 8; $i + +)
{
$produceOrder =get-random-inputobject $order;
$newOrder + + $produceOrder;
$order. Remove ($produceOrder);
}
$newPassword =@ ();
foreach ($i in $newOrder)
{
if ($i-eq 0)
{
$index =get-random-maximum 8;
$newPassword + + $figure [$index];
}
if ($i-eq 1)
{
$index =get-random-maximum 8;
$newPassword + + $figure [$index];
}
if ($i-eq 2)
{
$index =get-random-maximum 25;
$newPassword + + $capital [$index];
}
if ($i-eq 3)
{
$index =get-random-maximum 25;
$newPassword + + $capital [$index];
}
if ($i-eq 4)
{
$index =get-random-maximum 25;
$newPassword + + $lowercase [$index];
}
if ($i-eq 5)
{
$index =get-random-maximum 25;
$newPassword + + $lowercase [$index];
}
if ($i-eq 6)
{
$index =get-random-maximum 12;
$newPassword + + $specialCharacter [$index];
}
if ($i-eq 7)
{
$index =get-random-maximum 12;
$newPassword + + $specialCharacter [$index];
}
}
return $newPassword-join "";
}
Test Results: