计算字符的ASCII码,再适当的变换即可

解决方案 »

  1.   

    异或最好了:for i:=1 to length(s) do
              s[i]:=chr(ord(s[i])xor 255);
    F:TextFile;
    S:string;Assignfile(F1,'file1.txt');
        Rewrite(F1);
        for i:=0 to memo1.Lines.Count-1 do
          begin
            s:=memo1.lines.Strings[i];
            for j:=1 to length(s) do
              s[j]:=chr(ord(s[j])xor 255);//写时加密
            writeln(F1,s);
          end;
       CloseFile(F1);Assignfile(F1,'file1.txt');
        Reset(F1);
        while not Eof(F1) do
          begin
            Readln(F1,s);
            for i:=1 to length(s) do
              s[i]:=chr(ord(s[i])xor 255);//读时解密;
            memo1.lines.Add(s);
          end;  
       CloseFile(F1);
      

  2.   

    我这儿有控件Base64,根据RFC2045定义规范加密.
    // uTBase64 v1.0 - Simple Base64 encoding/decoding class
    // Base64 described in RFC2045, Page 24, (w) 1996 Freed & Borenstein
    // Delphi implementation (w) 1999 Dennis D. Spreen ([email protected])
    // This unit is freeware. Just drop me a line if this unit is useful for you.
    email:[email protected]
    不过,如果真要提高还是建议你去看一些加密算法方面的书籍,这个只能救急,治标不治本。
      

  3.   

    Delphi编程实现文本文件的加密,有人知道吗?
      

  4.   

    与其自己编写一些很可能不成熟的加密算法,还不如直接调用Windows的api函数,专业多了。具体,请看msdn中的CryptoAPI。