unit uCrypt;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;type
const
C1=52845;
C2=22719;
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
  function Encrypt(const S:string;Key:Word):string;
  function Decrypt(const S:string;Key:Word):string;    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}function Encrypt(const S:string;Key:Word):string;
var
I:byte;
begin
SetLength(Result,Length(S));
for I:=1 to Length(S) do begin
Result[I]:=char(byte(S[I])xor(Key shr8));
Key:=(byte(Result[I])+Key)*C1+C2;
end;
end;function Decrypt(const S:string;Key:Word):string;
var
I:byte;
begin
SetLength(Result,Length(S));
for I:=1 to Length(S) do begin
Result[I]:=char(byte(S[I])xor(Key shr8));
Key:=(byte(S[I])+Key)*C1+C2;
end;
end;
end.[Error] Unit1.pas(1): Unit identifier 'uCrypt' does not match file name
[Error] Unit1.pas(10): Identifier expected but 'CONST' found
[Error] Unit1.pas(13): Expression expected but 'CLASS' found
[Error] Unit1.pas(14): Constant expression expected
[Error] Unit1.pas(16): '=' expected but identifier 'public' found
[Error] Unit1.pas(17): ';' expected but 'FUNCTION' found
[Error] Unit1.pas(21): 'IMPLEMENTATION' expected but ';' found
[Error] Unit1.pas(24): '..' expected but ';' found
[Error] Unit1.pas(26): '.' expected but 'IMPLEMENTATION' found
[Error] Unit1.pas(17): Unsatisfied forward or external declaration: 'Encrypt'
[Error] Unit1.pas(18): Unsatisfied forward or external declaration: 'Decrypt'
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'
那个是窗体文件,如果改成单元文件,这样行不行?unit uCrypt;interface
const
C1=52845;
C2=22719;
implementation
function Encrypt(const S:string;Key:Word):string;
var
I:byte;
begin
SetLength(Result,Length(S));
for I:=1 to Length(S) do begin
Result[I]:=char(byte(S[I])xor(Key shr8));
Key:=(byte(Result[I])+Key)*C1+C2;
end;
end;function Decrypt(const S:string;Key:Word):string;
var
I:byte;
begin
SetLength(Result,Length(S));
for I:=1 to Length(S) do begin
Result[I]:=char(byte(S[I])xor(Key shr8));
Key:=(byte(S[I])+Key)*C1+C2;
end;
end;
end.