This message was edited by Shadow1 at 2005-9-29 4:5:17
hi im currently writing a program that creates a password and encrypts it. i have this sussed but with my other programm thats ment to decrypt it. it isnt working i want to be able to create a password and store it in a text file and use a second program to read from the file decrypt the text and check if the text is correct to the inputted password ill include both program codes below if any 1 can help me direct where im going wrong ill be very greatfull
thanks shadow1
1st program that creats password
program password;
uses crt;
const null= '';
var i: integer;
ch:char;
origphrase, codedphrase: string[80];
function TRANSLATE (ch:char):char;
var loc: integer;
alphabet, key:string[26];
begin
alphabet:= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
key:= 'JVKM9LON8IBHDCREFZU1PYG7XASQ2WTjvkml3onibhdc4r0efzup5y6gxasqwt';
loc:= pos (ch, alphabet);
if loc > 0 then translate:= key[loc]
else translate:= ch
end;
begin
write ('type a password ');
readln (origphrase);
codedphrase:=null;
for i := 1 to length (origphrase) do
begin
ch:=origphrase[i];
codedphrase:=codedphrase+translate (ch)
end;
writeln (codedphrase)
end.
2nd (program that is ment to decode and check)
program enter;
uses crt;
var
c: char;
pas: string;
const null= '';
var i: integer;
passfile: text ;
ch:char;
origphrase, codedphrase: string[80];
function TRANSLATE (ch:char):char;
var loc: integer;
alphabet, key:string[62];
begin
alphabet:= 'JVKM9LON8IBHDCREFZU1PYG7XASQ2WTjvkml3onibhdc4r0efzup5y6gxasqwt';
key:= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ';
loc:= pos (ch, alphabet);
if loc > 0 then translate:= key[loc]
else translate:= ch
end;
begin
clrscr;
writeln ('please enter password');
repeat
c:=readkey;
if c<>#13 then pas:=pas+c; {add the character to the password}
write('*');
until c=#13;
assign (passfile, 'a:\pass.txt');
reset (passfile);
while not eof (passfile) do
begin
readln (passfile, pas);
writeln (pas);
end;
close (passfile);