Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 913044b0fd | |||
| 4058ac1bc4 | |||
| bdc37a5c99 | |||
| 31b561e386 | |||
| 885e1128bf | |||
| 6292426e52 | |||
| 47cca9c323 | |||
| 72e7e687c7 |
+213
@@ -0,0 +1,213 @@
|
||||
Groupe :
|
||||
- FRAMERY Karl
|
||||
- ABRAHAM Ozvann
|
||||
|
||||
|
||||
## 1. Dessiner le graphe
|
||||
|
||||
|
||||
### C2
|
||||

|
||||
|
||||
### C4
|
||||

|
||||
|
||||
### P2
|
||||

|
||||
|
||||
### P3
|
||||

|
||||
|
||||
### J2
|
||||

|
||||
|
||||
### J6
|
||||

|
||||
|
||||
|
||||
## 2. Compter les décisions
|
||||
|
||||
|
||||
### J1-J6
|
||||
|
||||
- [ ] J1 = 1
|
||||
- [ ] J2 = 2 + 1 = 3
|
||||
- [ ] J3 = 7 + 1 = 8
|
||||
- [ ] J4 = 8 + 1 = 9
|
||||
- [ ] J5 = 10 + 1 = 11
|
||||
- [ ] J6 = 8 + 1 = 9
|
||||
|
||||
|
||||
### C1-C6
|
||||
|
||||
- [ ] C1 = 1
|
||||
- [ ] C2 = 2 + 1 = 3
|
||||
- [ ] C3 = 2 + 1 = 3
|
||||
- [ ] C4 = 7 + 1 = 8
|
||||
- [ ] C5 = 7 + 1 = 8
|
||||
- [ ] C6 = 10 + 1 = 11
|
||||
|
||||
|
||||
### P1-P5
|
||||
|
||||
- [ ] P1 = 1
|
||||
- [ ] P2 = 2 + 1 = 3
|
||||
- [ ] P3 = 2 + 1 = 3
|
||||
- [ ] P4 = 2 + 1 = 3
|
||||
- [ ] P5 = 13 + 1 = 14
|
||||
|
||||
|
||||
### Complexité max : P5 = 14
|
||||
|
||||
|
||||
## 3. Classer
|
||||
|
||||
|
||||
|
||||
- [ ] C1 -> <span style="color:blue"> simple </span>
|
||||
- [ ] C2 -> <span style="color:blue"> simple </span>
|
||||
- [ ] C3 -> <span style="color:blue"> simple </span>
|
||||
- [ ] C4 -> <span style="color:yellow"> moyen </span>
|
||||
- [ ] C5 -> <span style="color:yellow"> moyen </span>
|
||||
- [ ] C6 -> <span style="color:red"> complexe </span>
|
||||
|
||||
- [ ] J1 -> <span style="color:blue"> simple </span>
|
||||
- [ ] J2 -> <span style="color:blue"> simple </span>
|
||||
- [ ] J3 -> <span style="color:red"> complexe </span>
|
||||
- [ ] J4 -> <span style="color:red"> complexe </span>
|
||||
- [ ] J5 -> <span style="color:red"> complexe </span>
|
||||
- [ ] J6 -> <span style="color:red"> complexe </span>
|
||||
|
||||
- [ ] P1 -> <span style="color:blue"> simple </span>
|
||||
- [ ] P2 -> <span style="color:blue"> simple </span>
|
||||
- [ ] P3 -> <span style="color:yellow"> moyen </span>
|
||||
- [ ] P4 -> <span style="color:yellow"> moyen </span>
|
||||
- [ ] P5 -> <span style="color:red"> complexe </span>
|
||||
|
||||
|
||||
|
||||
## 4. Justifier les cas particuliers
|
||||
|
||||
|
||||
### C3
|
||||
|
||||
```
|
||||
return (annee % 4 == 0 && annee % 100 != 0) || annee % 400 == 0;
|
||||
```
|
||||
|
||||
L'utilisation des <&&> et <||> sont nécessaire pour une compréhention plus simple du code, sans leurs utilisation le code aurait nécéssité des if / else randant le code plus long et moins compréhensible / lisible.
|
||||
|
||||
|
||||
|
||||
## 5. Refactoriser
|
||||
|
||||
|
||||
### P5
|
||||
|
||||
```
|
||||
def analyser_mot_de_passe(mdp, login=None):
|
||||
problemes = []
|
||||
if len(mdp) < 12:
|
||||
problemes.append("trop court")
|
||||
majuscule = minuscule = chiffre = special = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
majuscule = True
|
||||
elif c.islower():
|
||||
minuscule = True
|
||||
elif c.isdigit():
|
||||
chiffre = True
|
||||
else:
|
||||
special = True
|
||||
if not (majuscule and minuscule):
|
||||
problemes.append("mélanger majuscules et minuscules")
|
||||
if not chiffre:
|
||||
problemes.append("ajouter un chiffre")
|
||||
if not special:
|
||||
problemes.append("ajouter un caractère spécial")
|
||||
if login and login.lower() in mdp.lower():
|
||||
problemes.append("ne pas contenir le login")
|
||||
for i in range(len(mdp) - 2):
|
||||
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
||||
problemes.append("éviter 3 caractères identiques")
|
||||
break
|
||||
if not problemes:
|
||||
return "fort", []
|
||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||
```
|
||||
|
||||
Devien une fois transformé :
|
||||
|
||||
```
|
||||
def analyser_mot_de_passe(mdp, login=None):
|
||||
problemes = []
|
||||
taille_mdp(mdp, problemes)
|
||||
majuscule = caractere_majuscule
|
||||
minuscule = caractere_minuscule
|
||||
chiffre = caractere_chiffre
|
||||
special = caractere_special
|
||||
problemes(majuscule, minuscule, chiffre, special, login, mdp, problemes)
|
||||
for i in range(len(mdp) - 2):
|
||||
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
||||
problemes.append("éviter 3 caractères identiques")
|
||||
break
|
||||
if not problemes:
|
||||
return "fort", []
|
||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||
|
||||
|
||||
|
||||
def problemes(majuscule, minuscule, chiffre, special, login=none, mdp, problemes[]):
|
||||
if not (majuscule and minuscule):
|
||||
problemes.append("mélanger majuscules et minuscules")
|
||||
if not chiffre:
|
||||
problemes.append("ajouter un chiffre")
|
||||
if not special:
|
||||
problemes.append("ajouter un caractère spécial")
|
||||
if login and login.lower() in mdp.lower():
|
||||
problemes.append("ne pas contenir le login")
|
||||
|
||||
|
||||
|
||||
def taille_mdp(mdp, problemes[]):
|
||||
if len(mdp) < 12:
|
||||
return problemes.append("trop court")
|
||||
|
||||
|
||||
|
||||
def caractere_majuscule(mdp):
|
||||
majuscule = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
majuscule = True
|
||||
return majuscule
|
||||
|
||||
|
||||
|
||||
def caractere_minuscule(mdp):
|
||||
minuscule = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
minuscule = True
|
||||
return minuscule
|
||||
|
||||
|
||||
|
||||
def caractere_chiffre(mdp):
|
||||
chiffre = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
chiffre = True
|
||||
return chiffre
|
||||
|
||||
|
||||
|
||||
def caractere_special(mdp):
|
||||
special = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
special = True
|
||||
return special
|
||||
```
|
||||
|
||||
### Complexité max de analyser_mot_de_passe : P5 = 5
|
||||
Reference in New Issue
Block a user