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.
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.
解决方案 »
- 请教:如何在一个Form中hint 一些字?
- 关于dbchart 控件读取静态数据的问题!
- 怪了,取拼音声母函数
- 求Delphi和ASP通用的加密、解决函数……
- 如何得到光标在窗体中的坐标?
- 求解弹砖块里小球碰到滑板反射角的算法.(算法哦!)
- quickreport的问题:一个常规的操作,但就是结果错误!
- 用SocketConnection来连接三层的服务器的时候,在启动的时候为什么会自动启动服务端啊?能不能不让他自动启动?
- 一个关于TM-U300A\B\C\D打印小票的小程序。要者,快来拿也。。。。。
- 在delphi中如何用sql把某个库的数据备份成数据文件(txt或doc文件)??
- 很弱的问题:求两个时间之间相隔分钟数
- delphi问题
还有就是type后面不可以有const,你可以把const放到type的前面。