kod:
program project1;
{$apptype console}
uses
sysutils, classes;
procedure decrypt(fn: string);
var
f1, f2: TFileStream;
b: Byte;
begin
f1 := TFileStream.Create(fn, fmOpenRead);
try
f2 := TFileStream.Create(fn+'.txt', fmCreate);
try
while f1.Position < f1.Size do
begin
b := f1.ReadByte;
b := not RolByte(b, 2);
f2.WriteByte(b);
end;
finally
f2.Free;
end;
finally
f1.Free;
end;
end;
begin
if FileExists(ParamStr(1)) then
decrypt(ParamStr(1));
end.
mój kod:
#include <fstream>
using namespace std;
void decrypt (string fn)
{
ifstream f1(fn.c_str(), ios::in | ios::binary);
ofstream f2("out.txt", ios::out | ios::trunc);
char byte;
while (f1 >> byte)
{
byte = ((byte << 2) | (byte >> (8-2)));
//negacja byte;
f2 << byte;
}
f2.close();
f1.close();
return;
}
int main(int argc, char* argv[])
{
decrypt (argv[1]);
return 0;
}
Opis problemu: nie umiem znegować wartości byte, operator ! nie działa poprawnie.
ps. jeżeli macie jakieś sugestie odnośnie programu proszę pisać :)
Dziękuję za pomoc.