PDA

View Full Version : Won't output (usually non ASCII) text. Not even the question marks.



R0b0t1
07-16-2008, 07:13 PM
It compiles, (Would someone try to run it in SCAR), as Pascal, and I hope in SCAR, but it won't output anything. Could anyone check to see if I'm missing something stupid?



program OneTimePad;

var
InText, PadText, OutText, State, LegAsc: String;
I, InLength, PadLength, tmp: Integer;

begin
{$IFNDEF DIVI} //Plain pascal?
WriteLn('Encrypt/decrypt (E/D): ');
ReadLn(State);
WriteLn('Use legal ASCII? (Y/N): ');
ReadLn(LegAsc);
WriteLn('Text to encrypt/decrypt: ');
ReadLn(InText);
WriteLn('Text to use as the pad: ');
ReadLn(PadText);
{$ELSE} //Scar?
State := ReadLn('Encrypt/decrypt (E/D): ');
LegAsc := ReadLn('Use legal ASCII? (Y/N): ');
InText := ReadLn('Text to encrpyt/decrypt: ');
PadText := ReadLn('Text to use as pad: ');
{$ENDIF}

InLength := Length(InText);
PadLength := Length(PadText);

if(UpCase(State) = 'E') then
if(UpCase(LegAsc) = 'N') then
for I := 1 to InLength do
begin
if(not I < PadLength) then tmp := I else tmp := I mod InLength;
OutText[I] := Chr((Ord(InText[I]) + Ord(PadText[tmp])) mod 256);
end
else if(UpCase(LegASc) = 'Y') then
for I := 1 to InLength do
begin
if(not I < PadLength) then tmp := I else tmp := I mod InLength;
OutText[I] := Chr(((Ord(UpCase(InText[I]))-65) + (Ord(UpCase(PadText[tmp]))-65) mod 26)+65);
end
else
WriteLn('Specify y/n for encryption style.')
else if(UpCase(State) = 'D') then
if(UpCase(LegAsc) = 'N') then
for I := 1 to InLength do
begin
if(not I < PadLength) then tmp := I else tmp := I mod InLength;
OutText[I] := Chr((Ord(InText[I]) - Ord(PadText[tmp])) mod 256);
end
else if(UpCase(LegAsc) = 'Y') then
for I := 1 to InLength do
begin
if(not I < PadLength) then tmp := I else tmp := I mod InLength;
OutText[I] := Chr(((Ord(UpCase(InText[I]))-65) - (Ord(UpCase(PadText[tmp]))-65) mod 26)+65);
end
else
WriteLn('Specify y/n for encryption style.')
else
WriteLn('Please specify D or E to Encrypt/Decrypt');

{$IFNDEF DIVI}
WriteLn('The ciphered text is: ', OutText);
{$ELSE}
WriteLn('The ciphered text is: ' + OutText);
{$ENDIF}
end.

PvH
07-16-2008, 08:00 PM
Hmm, I have no idea how delphi works, but I tried it for you in scar and I got this:p
Line 27: [Error] (27:4): Unknown identifier 'UpCase' in script
Wel.. Good luck fixing it, sorry that I can't help you (yet).

mastaraymond
07-16-2008, 08:07 PM
OutText[i] := Chr(((Ord(uppercase(InText[i]))-65) + (Ord(UpCase(PadText[tmp]))-65) mod 26)+65);

Line 38: [Error] (38:45): Type mismatch in script

Ehzor it doesn't compile in scarzor :(.

R0b0t1
07-16-2008, 09:36 PM
Damnit

Daniel
07-17-2008, 11:53 AM
This is pascal, not Delphi o_O. Also, where do you get a pascal compiler?

mastaraymond
07-17-2008, 03:31 PM
This is pascal, not Delphi o_O. Also, where do you get a pascal compiler?
Free pascal?

R0b0t1
07-17-2008, 09:00 PM
Yes :D


Pascal will compile in Delphi. As someone said, the only function that is apparently missing is UpCase();

Daniel
07-18-2008, 02:26 AM
Yes :D


Pascal will compile in Delphi. As someone said, the only function that is apparently missing is UpCase();
It does? Cool. Anyways, just replace it with Uppercase ;)