MATLAB Examples

Contents

% Demonstration of Create Passwords Function
% Alan Jennings
% This file is mean to provide usage examples for CreatePassword.m
% Using ‘rng shuffle’ in the code, shuffles the random number generator so
% that passwords cannot be recreated based on pseudorandom number generator
% seed.

Examples of calling:

Default Behavior:

CreatePassword % Default is 8 character password of all ASCII values
ans =
.=qJm<#3

5 characters, only lowercase letters and numbers

CreatePassword(5,0,-1,0,-1) %5 character password of only lowercase and numbers
ans =
mmjy1

Using single vector

CreatePassword([5,2,2,4])
% 5 (8 actually) character password with at least 2 lowercase, 2 uppercase
% and 4 numbers (no symbols due to no unalocated spaces)
ans =
66V0y8Eb

Using Length and vector

CreatePassword(5,[2,2,4])
% 5 (8 actually) character password with at least 2 lowercase, 2 uppercase
% and 4 numbers (no symbols due to no unalocated spaces)
ans =
30VP0sg0

Negative requirements mean characters will not be used

CreatePassword(8,[-1,-1,4])
%8 character password with at least 4 numbers and no lowercase or uppercase
CreatePassword(8,[-1,-1,4,-1])
%8 number password with no symbols
ans =
8326>>6'
ans =
92223827

User specified set, not checked for uniqueness

CreatePassword(18,-1,-1,-1,0,'6669')
% password using only the characters 6 and 9, (6 is three times more
% likely, so roughly 4 9's are expected, on average)
ans =
966696669696666969

Suggested useage

Call in a loop and then select one that fits your fancy

The list can be stored. As long as you can recognise yours, you can remind yourself, while another user would have to guess without having prior knowledge.

for n=1:30
    disp(CreatePassword(14,[2,2,4,2]))
end
d78<nUD8v3?w!F
`c,R2Tt6ewq#38
8iK0PK7-@l}6dq
]x8{a@|L*=0V04
lI86d&57h-B?=W
xa6wO54[X}YI8~
"ci\z1Q072<_tV
zx=7056DL;(7Vh
9J3H6-3cw5}wq!
5pA4j5FG8)t"UT
!`7R-AkI7t0e2>
5+8n;ZI88fk8fW
'T08G%X5"9kx,t
7'72Z_i5uE2$1J
it@9.5H=Q40H3:
WQ&1u;93Q5R9s#
.21JZ0Ke55THj^
j6O!At48i8N=s3
O#>8M4z8x9KS'b
S*7T9-,C2f3zsN
^2XXzMH1[y3zf0
Z.6b126>E(qq$p
358yB6yE}]mkL1
|Kks9844`J0{K(
1+YnS3R6g$_Q82
m4B9fr-79-2O^F
=/4q2HsPCHt857
"v\V9@:R9la8V4
'712'iMdpgDX=9
qU7|31|splH9^/