1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
| \documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{fp}
\usepackage[counter=mdp]{lcg}
\makeatletter
\newcount\nbchar
\newcount\charspec
\newcount\chiffre
\newcount\Lettre
\newcount\lettre
\newcount\nbdesecurite
\parindent=0pt
%%%%%%%%%%%%%%%%%%%%%%%générateur de mot de passe%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\genmdp@i{%commande reccursive
\chgrand[first=1,last=100]\rand%
\unless\ifnum\arabic{mdp}>\propchar%utilisation des caractères spéciaux si argument optionnel
\let\next=\relax%
\advance\charspec by 1 %
\chgrand[last=14]\rand%
\ifnum\arabic{mdp}=1\edef\m@tdepasse{\m@tdepasse ]}\fi%ajout au mdp
\ifnum\arabic{mdp}=2\edef\m@tdepasse{\m@tdepasse ù}\fi%
\ifnum\arabic{mdp}=3\edef\m@tdepasse{\m@tdepasse [}\fi%
\ifnum\arabic{mdp}=4\edef\m@tdepasse{\m@tdepasse @}\fi%
\ifnum\arabic{mdp}=5\edef\m@tdepasse{\m@tdepasse =}\fi%
\ifnum\arabic{mdp}=6\edef\m@tdepasse{\m@tdepasse :}\fi%
\ifnum\arabic{mdp}=7\edef\m@tdepasse{\m@tdepasse ?}\fi%
\ifnum\arabic{mdp}=8\edef\m@tdepasse{\m@tdepasse \%}\fi%
\ifnum\arabic{mdp}=9\edef\m@tdepasse{\m@tdepasse \$}\fi%
\ifnum\arabic{mdp}=10\edef\m@tdepasse{\m@tdepasse *}\fi%
\ifnum\arabic{mdp}=11\edef\m@tdepasse{\m@tdepasse .}\fi%
\ifnum\arabic{mdp}=12\edef\m@tdepasse{\m@tdepasse !}\fi%
\ifnum\arabic{mdp}=13\edef\m@tdepasse{\m@tdepasse ;}\fi%
\ifnum\arabic{mdp}=14\edef\m@tdepasse{\m@tdepasse \#}\fi%
\else%
\chgrand[first=1,last=100]\rand%
\ifnum\arabic{mdp}>\propnombre%utilisation de lettres en fonction du "taux" déclaré en argument #1
\let\next=\relax%
\chgrand[last=52]\rand%
\ifnum\arabic{mdp}<27%lettres minuscules
\advance\lettre by 1 %
\edef\m@tdepasse{\m@tdepasse\alph{mdp}}%ajout au mdp
\else%
\advance\Lettre by 1 %lettres majuscule
\addtocounter{mdp}{-26}%
\edef\m@tdepasse{\m@tdepasse\Alph{mdp}}%ajout au mdp
\fi%
\else%
\let\next=\relax%
\advance\chiffre by 1 %chiffres
\chgrand[last=10]\rand%
\addtocounter{mdp}{-1}%
\edef\m@tdepasse{\m@tdepasse\arabic{mdp}}%ajout au mdp
\fi%
\fi%
\advance\nbchar by 1 %
\ifnum\nbchar<\l@ngmdp\def\next{\genmdp@i}\fi\next}%fin de la reccursion si compteur=longueur du mdp. \next lance la reccursion qui est terminale
\newcommand\motdepasse[3][0]{%
\def\propnombre{#2}%
\def\propchar{#1}
\def\l@ngmdp{#3}%
%\let\secure\@empty%
\def\m@tdepasse{ }%
\def\longmdp{#2}
\nbchar=0% initialisation des compteurs
\charspec=0%
\chiffre=0%
\nbdesecurite=0%
\Lettre=0%
\lettre=0%
\genmdp@i% lance la reccursion
\hrulefill\par\begin{center}%mise en page du texte et du mot de passe
\texttt{\m@tdepasse}%
\end{center}\solidite\par La robustesse du mot de passe est : %
\medskip\barrepourcent\medskip\par}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%testeur de sécurité%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\solidite{%
%%%%%%%%%%%%%%%%%%%%%%%%bonus et penalités %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifnum\chiffre<\l@ngmdp%
\multiply\chiffre by 4\advance\nbdesecurite by\chiffre %
\else
\advance\nbdesecurite by -\l@ngmdp %
\advance\nbdesecurite by -\l@ngmdp %
\fi
%bonus nb de chiffres, accordé que s'ils ne sont pas seuls,si seuls une pénalité est imposée
\ifnum\Lettre>0\advance\Lettre by -\l@ngmdp \fi%bonus majuscules
\multiply\Lettre by -2 %
\ifnum\charspec=0\ifnum\chiffre=0%
\ifnum\lettre=0%
\advance\Lettre by -\l@ngmdp%Pénalité si majuscules seules
\advance\Lettre by -\l@ngmdp%
\else%
\ifnum\Lettre=0%
\advance\lettre by -\l@ngmdp%pénalité si minuscules seules
\advance\lettre by -\l@ngmdp%
\fi\fi\fi\fi
\ifnum\lettre>0\advance\lettre by -\l@ngmdp \fi%bonus minuscule
\multiply\lettre by -2 %
\edef\l@ngmdp{\number\numexpr\l@ngmdp*4}% bonus nb de caractères
\advance\nbdesecurite by\l@ngmdp %
\multiply\charspec by 6 % bonus nb de caractères spéciaux
\advance\nbdesecurite by\charspec %
\advance\nbdesecurite by\Lettre %
\advance\nbdesecurite by\lettre %
\def\result{\the\nbdesecurite}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%barre de pourcentage%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\barrepourcent{%
\FPeval{\resulta}{\the\nbdesecurite/100}%
\FPeval{\resultb}{1-\resulta}%
\ifnum\nbdesecurite>100%
\textbf{excellente} (100\,\%)\par\fbox{\color{green!90!black!}%
\vrule height1.5ex width \linewidth}%
\else
\ifnum\nbdesecurite<20%
\textbf{très mauvaise} (\the\nbdesecurite\,\%)%
\par\fbox{\color{red!40!black}%
\vrule height1.5ex width \resulta\linewidth depth0pt%
\vrule height0pt width \resultb\linewidth depth0pt}%
\else%
\ifnum\nbdesecurite<40%
\textbf{mauvaise} (\the\nbdesecurite\,\%)%
\par\fbox{\color{red!95!black}%
\vrule height1.5ex width \resulta\linewidth depth0pt%
\vrule height0pt width \resultb\linewidth depth0pt}%
\else
\ifnum\nbdesecurite<60%
\textbf{moyen} (\the\nbdesecurite\,\%)%
\par\fbox{\color{orange!95!black!}%
\vrule height1.5ex width \resulta\linewidth depth0pt%
\vrule height0pt width \resultb\linewidth depth0pt}%
\else
\ifnum\nbdesecurite<80%
\textbf{bon} (\the\nbdesecurite\,\%)%
\par\fbox{\color{yellow!90!black!}%
\vrule height1.5ex width \resulta\linewidth depth0pt%
\vrule height0pt width \resultb\linewidth depth0pt}%
\else
\ifnum\nbdesecurite<100%
\textbf{bon} (\the\nbdesecurite\,\%)%
\par\fbox{\color{green!50!black!}%
\vrule height1.5ex width \resulta\linewidth depth0pt%
\vrule height0pt width \resultb\linewidth depth0pt}%
\fi
\fi
\fi
\fi
\fi
\fi%
}
\makeatother
\begin{document}
{\Large \textbf{Mots de passe longueur 12 sans caractères spéciaux:}}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\motdepasse{50}{12}\par
\bigskip
{\Large \textbf{Mots de passe longueur 8 sans caractères spéciaux:}}\par
\motdepasse{50}{8}\par
\motdepasse{0}{8}\par
\motdepasse{50}{8}\par
\motdepasse{50}{8}\par
\motdepasse{50}{8}\par
\motdepasse{50}{8}\par
\motdepasse{50}{8}\par
\motdepasse{50}{8}\par
\motdepasse{50}{8}\par
\bigskip
{\Large \textbf{Mots de passe longueur 12 avec caractères spéciaux:}}\par
\motdepasse[50]{50}{12}\par
\motdepasse[50]{50}{12}\par
\motdepasse[50]{50}{12}\par
\motdepasse[50]{50}{12}\par
\motdepasse[80]{50}{12}\par
\motdepasse[30]{50}{12}\par
\motdepasse[10]{50}{12}\par
\bigskip
{\Large \textbf{Mots de passe de longueur 8 sans chiffre avec et sans caractères spéciaux:}}\par
\motdepasse{0}{8}\par
\motdepasse[0]{0}{8}\par
\motdepasse[50]{0}{8}\par
\motdepasse[100]{0}{8}\par
\motdepasse[80]{0}{8}\par
\motdepasse[20]{0}{8}\par
\bigskip
{\large\textbf{Mots de passe de longueur 6 sans lettre avec et sans caractères spéciaux :}}\par
\motdepasse{100}{6}\par
\motdepasse[50]{100}{6}\par
\motdepasse{100}{6}\par
\motdepasse[30]{100}{6}\par
\motdepasse[70]{100}{6}\par
\motdepasse{100}{6}\par
\bigskip
{\Large \textbf{Mots de passe de longueur 10 sans lettre avec et sans caractères spéciaux :}}\par
\motdepasse{100}{10}\par
\motdepasse[50]{100}{10}\par
\motdepasse{100}{10}\par
\motdepasse[30]{100}{10}\par
\motdepasse[70]{100}{10}\par
\motdepasse{100}{10}\par
\end{document} |
Partager