生成,并记录一个随机数。将要转换的字符变成成ASC代码,根据生成的随机数,取第n位就行了。

解决方案 »

  1.   

    var
      s,str1:string;
      str:char;
      k:integer;
    begin
      s:='tsinghua';
      str1:='';
      for i:=1 to length(s) do
      str:=s[i];
      k:=ord(str);
      k:=K+2;
      str1:=concat(str1,chr(k));
    end;
    //结果:str1='vukpijwc'哈哈,给分!!!!!!!!!!111
      

  2.   

    给你一个函数:
    const
            C1=88665;  //两个密钥
            C2=53419; //
    function Encrypt(s:string;key:WORD):String;implementation
    function Encrypt(s:string;key:WORD):String;
    var
        I:Byte;
        slen:integer;
        res:string;
    begin
        slen:= Length(s);
        setlength(s,slen);
        setlength(res,slen);
        for i:=1 to slen do begin
            Res[i] := char(byte(s[i]) xor (key shr 8));
            key :=(byte(Res[i])+key)*C1+C2;
        end;
        result := res;
    end;如:  ENCRYPT('This is a car',56788); key=56788.
      

  3.   

    我有一个控件,如果你想要,请给我来信
    [email protected]
      

  4.   

    经典之中的经典:unit Crypt32;
    {
    *************************************************************************
    * Name: Crypt32.Pas    *
    * Description: 32 bits encode/decode module    *
    * 2^96 variants it is very high to try hack *
    * Purpose: Good for encrypting passwors and text *
    * Security: avoid use StartKey less than 256 *
    * if it use only for internal use you may use default  *
    * key, but MODIFY unit before compiling *
    * Call: Encrypted := Encrypt(InString,StartKey,MultKey,AddKey) *
    * Decrypted := Decrypt(InString,StartKey)    *
    * Parameters: InString = long string (max 2 GB) that need to encrypt *
    * decrypt    *
    * MultKey = MultKey key                *
    * AddKey = Second key                *
    * StartKey = Third key                *
    * (posible use defaults from interface)    *
    * Return: OutString = result string    *
    * Editor: Besr viewed with Tab stops = 2, Courier new *
    * Started: 01.08.1996    *
    * Revision: 22.05.1997 - ver.2.01 converted from Delphi 1 *
    * and made all keys as parameters, before only start key *
    * Platform: Delphi 2.0, 3.0     *
    *  work in Delphi 1.0, 2^48 variants, 0..255 strings *
    * Author: Anatoly Podgoretsky    *
    *  Base alghoritm from Borland    *
    * Address: Vahe 4-31, Johvi, Estonia, EE2045, tel. 61-142     *
    * [email protected]    *
    * Status: Freeware, but any sponsor help will be appreciated here *
    * need to buy books, shareware products, tools etc *
    *************************************************************************
    * Modified:     Supports Delphi 1.0 & 2.0                          *
    *               Overflow checking removed                          *
    * By:           Martin Djern鎠                                     *
    * e-mail:       [email protected]                            *
    * web:          einstein.ot.dk/~djernaes                           *
    *************************************************************************
    }
    interfaceconst
      StartKey = 981;   {Start default key}
      MultKey   = 12674; {Mult default key}
      AddKey   = 35891; {Add default key}function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
    function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;implementation{$R-}
    {$Q-}
    {*******************************************************
     * Standard Encryption algorithm - Copied from Borland *
     *******************************************************}
    function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
    var
      I : Byte;
    begin
      Result := '';
      for I := 1 to Length(InString) do
      begin
        Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
        StartKey := (Byte(Result[I]) + StartKey) * MultKey + AddKey;
      end;
    end;
    {*******************************************************
     * Standard Decryption algorithm - Copied from Borland *
     *******************************************************}
    function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
    var
      I : Byte;
    begin
      Result := '';
      for I := 1 to Length(InString) do
      begin
        Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
        StartKey := (Byte(InString[I]) + StartKey) * MultKey + AddKey;
      end;
    end;
    {$R+}
    {$Q+}end.