Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program cryptage;
- uses WinCrt;
- type
- MAT= array[1..200,1..10] OF char;
- var
- cle:string;
- fs,fc:text;
- s:integer;
- function verif(cle:string):Boolean;
- VAR i:Byte;
- begin
- i:=1;
- while(cle[i] in['A'..'Z']) AND (i<=Length(cle)) Do
- i:=i+1;
- verif:= i>length(cle);
- end;
- procedure saisie(VAR cle:string);
- begin
- repeat
- write('Veuillez saisir le clé du cryptage:');
- readln(cle);
- until (length(cle) in[5..10]) AND (verif(cle));
- end;
- procedure espace(x:string;s:integer);
- begin
- if Length(x) mod s <> 0
- then
- Repeat
- x:=x+' ';
- until length(x) mod s = 0;
- end;
- procedure rempm(Var M:mat;taille,s:integer;x:string);
- var l,c:integer;
- begin
- for l:=1 to taille do
- begin
- for c:=1 to s do
- begin
- M[l,c] := x[1];
- delete(x,1,1);
- end;
- end;
- end;
- procedure rempfc(var fc:text;M:MAT;s,taille:integer;cle:string);
- Var l,c:integer;
- ch,bigboi:string;
- begin
- ReWrite(fc);
- bigboi:='';
- for c:= 1 to s do
- begin
- for l:=1 to taille do
- begin
- ch:=ch[c];
- ch:= ch + M[l,c];
- end;
- bigboi:=bigboi + ch;
- end;
- writeln(fc,bigboi);
- close(fc);
- end;
- Procedure crypt_aff(VAR fs,fc:text ; cle:string; s:integer);
- Var
- M:MAT;
- taille:integer;
- x,ch,w:string;
- begin
- reset(fs);
- while not(eof(fs)) do
- begin
- readln(fs,x);
- espace(x,s);
- taille:= length(x) div s;
- rempm(M,taille,s,x);
- rempfc(fc,M,s,taille,cle);
- end;
- close(fs);
- reset(fc);
- while not(eof(fc)) do
- begin
- readln(fc,w);
- writeln(w);
- end;
- close(fc);
- end;
- begin
- assign(fs,'C:\Pascal\BAC_PRATIQUE_2017\Source.txt');
- assign(fc,'C:\Pascal\BAC_PRATIQUE_2017\Crypt.txt');
- saisie(cle);
- s:= length(cle);
- Crypt_aff(fs,fc,cle,s);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement