请问谁有base64的加解密算法

解决方案 »

  1.   

    delphi里有base64的加密解密的控件吧!
      

  2.   

    1,base64 不是加密算法。2、delphi有base64控件,对于d6,你可以在id***控件面板上找到,也可以在fastnet面板上面找到.
      

  3.   

    如果你嫌用控件效率低,文件大,那你就随便在google里面查找“delphi base64”,无数的源代码等着你下载
      

  4.   

    这种相关代码很容易找的,楼主好像有点太……
    一下引自猛料Base64编码:首先定义一个常量
    const
    BaseTable : String   = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';function FindInTable(CSource : Char):Integer;
    begin
       Result := Pos(String(CSource),BaseTable) -1;
    end;//Base64解码函数
    function DecodeBase64(Source : String):String;
    var
    SrcLen,Times,I : Integer;
    x1,x2,x3,x4,xt : Byte;
    begin
    Result := '';
    SrcLen := Length(Source);
    Times  := SrcLen div 4;
    for I := 0 to Times -1 do
    begin
    x1 := FindInTable(Source[1+I*4]);
    x2 := FindInTable(Source[2+I*4]);
    x3 := FindInTable(Source[3+I*4]);
    x4 := FindInTable(Source[4+I*4]);
    x1 := x1 shl 2;
    xt := x2 shr 4;
    x1 := x1 or xt;
    x2 := x2 shl 4;
    Result := Result + chr(x1);
    if x3= 64 then break;
    xt := x3 shr 2;
    x2 := x2 or xt;
    x3 := x3 shl 6;
    Result := Result + chr(x2);
    if x4 = 64 then break;
    x3 := x3 or x4;
    Result := Result + chr(x3);
    end;
    end;function EncodeBase64(Source:string):string; //base64 编码
    var
    Times,LenSrc,i:integer;
    x1,x2,x3,x4:char;
    xt:byte;
    begin
    result:='';
    LenSrc:=length(Source);
    if LenSrc mod 3 =0 then Times:=LenSrc div 3
    else Times:=LenSrc div 3 + 1;
    for i:=0 to times-1 do
    begin
    if LenSrc >= (3+i*3) then
    begin
    x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
    xt:=(ord(Source[1+i*3]) shl 4) and 48;
    xt:=xt or (ord(Source[2+i*3]) shr 4);
    x2:=BaseTable[xt+1];
    xt:=(Ord(Source[2+i*3]) shl 2) and 60;
    xt:=xt or (ord(Source[3+i*3]) shr 6);
    x3:=BaseTable[xt+1];
    xt:=(ord(Source[3+i*3]) and 63);
    x4:=BaseTable[xt+1];
    end
    else if LenSrc>=(2+i*3) then
    begin
    x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
    xt:=(ord(Source[1+i*3]) shl 4) and 48;
    xt:=xt or (ord(Source[2+i*3]) shr 4);
    x2:=BaseTable[xt+1];
    xt:=(ord(Source[2+i*3]) shl 2) and 60;
    x3:=BaseTable[xt+1];
    x4:='=';
    end else
    begin
    x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
    xt:=(ord(Source[1+i*3]) shl 4) and 48;
    x2:=BaseTable[xt+1];
    x3:='=';
    x4:='=';
    end;
    result:=result+x1+x2+x3+x4;
    end;
    end;