免费Pascal和数组类型的麻烦

时间:2011-10-18 03:49:16

标签: arrays types freepascal

文档暗示这是返回字节数组的函数的语法。我做错了什么?

$ fpc ios7crypt.pas
ios7crypt.pas(3,25) Error: Type identifier expected
ios7crypt.pas(3,25) Fatal: Syntax error, ";" expected but "ARRAY" found
Fatal: Compilation aborted

ios7crypt.pas:

program IOS7Crypt;

function XlatPrime () : array of byte;
begin
    XlatPrime := (
        $64, $73, $66, $64, $3b, $6b, $66, $6f,
        $41, $2c, $2e, $69, $79, $65, $77, $72,
        $6b, $6c, $64, $4a, $4b, $44, $48, $53,
        $55, $42, $73, $67, $76, $63, $61, $36,
        $39, $38, $33, $34, $6e, $63, $78, $76,
        $39, $38, $37, $33, $32, $35, $34, $6b,
        $3b, $66, $67, $38, $37
    );
end;

function Encrypt (hash : string) : string;
begin
    Encrypt := 'abc';
end;

function Decrypt (hash : string) : string;
begin
    Decrypt := 'abc';
end;

var
    password : string;
    hash : string;
begin
    password := 'abc';

    hash := Encrypt(password);

    password := Decrypt(hash);

    write('Password: ');
    writeln(password);
end.

1 个答案:

答案 0 :(得分:1)

适合我:

const
    XlatSize = 53;
    XlatPrime : array[0 .. XlatSize - 1] of byte = (
        $64, $73, $66, $64, $3b, $6b, $66, $6f,
        $41, $2c, $2e, $69, $79, $65, $77, $72,
        $6b, $6c, $64, $4a, $4b, $44, $48, $53,
        $55, $42, $73, $67, $76, $63, $61, $36,
        $39, $38, $33, $34, $6e, $63, $78, $76,
        $39, $38, $37, $33, $32, $35, $34, $6b,
        $3b, $66, $67, $38, $37
    );