Explorer les Livres électroniques
Catégories
Explorer les Livres audio
Catégories
Explorer les Magazines
Catégories
Explorer les Documents
Catégories
cryptage
lecture()
crypter(msg)
Verif(msg)
remplir(msg,t,n) dist(t,n,t1)
Programme principal
cryptage
fonction
fonction
lecture()
crypter(msg)
fonction
procedure
procedure
Verif(msg)
dist(t,n,t1)
remplir(msg,t,n)
Algorithme du programme principal :
T.D.O.G
Algorithme cryptage
objet type
Début
msg chaine
msg ← lecture()
s chaine
s←crypter (msg)
lecture fonction
Écrire("Le message crypté est ",s) crypter fonction
fin
Algorithme de la fonction lecture
Fonction lecture () :chaine
T.D.O.L
Début objet type
Répéter
Ecrire ("taper le message : ") msg chaine
Lire(msg) verif fonction
Jusqu’à (verif(msg)et((pos (" ",msg)=-1))
Retourner(msg)
fin
Algorithme de la function verif
fonction verif (ch : chaine) : booléen
Début T.D.O.L
dep ← ".,;:!?"
i←0 objet type
valide ← vrai dep chaine
tantque valide et (i<long(ch)) faire
i entier
si(pos(ch[i],dep)≠ -1)alors
valide ← faux valide booléen
sinon
i ← i+1
finsi
Fin tantque
Retourner(valide)
fin
T.D.N.T
Algorithme de la fonction crypter type
Fonction crypter (msg:chaine) :chaine
Début Tab=tableau de 50 chaines
Remplir(msg,T,i)
dist(T,i,T1)
ch ← ""
Pour j de 0 à long(T[0]) faire
ch ← ch+T1[j]+" "
Fin pour
T.D.O.L
ch ← effacer(ch,long(ch)-1,long(ch))
Retourner(ch)
fin objet type
T,T1 Tab
i,j entier
ch chaine
Algorithme de la procedure remplir T.D.O.L
Procedure remplir (msg:chaine;@T:tab;@i:entier)
Début objet type
i←0 p entier
ch ←msg+“ "
max ←0 k entier
Tantque (ch≠"") faire j entier
p ← pos(“ “,ch) l entier
T[i] ←souschaine(ch,0, p))
ch ←effacer(ch,0, p+1) ch chaine
i← i+1
si (p>max) alors
max ←p
finsi
Fin tantque
Pour j de 0 à (i-1) faire
l ←long(T[j])
pour k de 1 à (max-l) faire
T[j] ←T[j]+"*“
fin pour
Fin pour
fin
Algorithme de la procedure dist T.D.O.L
Procedure dist (t:tab;r:entier;@T1:tab)
Début objet type
Pour k de 0 à r faire k entier
ch ←T[k]
pour j de 0 à long(ch)-1 faire j entier
T1[j] ←T1[j]+ch[j] ch chaine
fin pour
Fin pour
fin
import numpy as np # module remplir # module crypter
# module verif def remplir(t,msg): def crypter (msg):
def verif(ch): ch=msg+' ' T=np.array(['']*20,dtype=(str,20))
dep=".,;:!?" max=0 i=remplir(T,msg)
i=0 i=0 T1=np.array(['']*len(T[0]),dtype=(str,i))
valide=True while(ch!=''): dist(T,i,T1)
while valide and(i<len(ch)): p=ch.find(" ") ch = ""
if(dep.find(ch[i])!=-1): t[i]=ch[:p] for j in range(len(T[0])):
valide=False ch=ch[p+1:] ch = ch+T1[j]+" "
else: i=i+1 ch =ch[:len(ch)-1]
i=i+1 if(p>max): return(ch)
return(valide) max=p #le prog principal
# module lecture for j in range(i): msg=lecture()
def lecture(): l=len(t[j]) s=crypter(msg)
ok=False for k in range(1,max-l+1): print(s)
while not(ok): t[j]=t[j]+'*'
msg=input("msg= ") return (i)
ok=verif(msg)and(msg.find(' ')==-1) #module dist
return msg def dist (T,r,T1):
for k in range(r):
ch=T[k]
for j in range(len(ch)):
T1[j]=str(T1[j])+ch[j]