如何对文件进行加密/解密?
想把文件C:\123.txt进行加密
基本思想是把文件读入流,然后按位或字节处理后,写入文件,实现加密.
不知道这样做是否可行,执行会出错,求指点
var str : TFileStream;
enc : TFileStream;
i : integer;
s : string;
buf : byte;
s:='c:\123.txt';
str:=TFileStream.create(s,fmopenread);
enc:=TFileStream.create('c:\123_enc.txt',fmcreate);
for i:=1 to str.size do
begin
str.readbuffer(buf,8);
buf:=buf xor 8;
enc.write(buf,8);
end;