字符串移位加密???
例如:str:=FBKMZ542
用DELPHI 加密,实现字符简单移位
例如通过如下方式加密:
   s:='FBKMZ542';
   for   i:=1   to   length(s)   do
   begin
     s[i]:=chr(ord(s[i])xor   250);
   end;
或:只对字符进行加3减3操作或者:
   for i:=1 to length(s) do
    begin
       s[i]:=chr(ord(s[i])shl 2);
    end;最好用后者加密!
关键是要用VBscript脚本解密???

解决方案 »

  1.   

    你就用第一段程序不行吗?你说的VBScript脚本是用于ASP还是什么的?
      

  2.   

    对,是ASP的VBSCRIPT,在服务端进行解密
      

  3.   

    服务端解密?是你自己做解密过程还是IIS来做?如果是IIS来做的话,你就要用MS Script Encode来加密了,要满足它的加密协议。如果是你自己解密,那随便怎么加密解密都可以啊,给一个加密解密的程序吧:function Encode(source : string):string;  //加密
    var
      Source_Len,Len : integer;
      Count,c : integer;
      a1,a2 : byte;
      ind : dword;
      Encode_Str : string;
    begin
      Result := '';
      Encode_Str := '';
      Len := 0;
      a1 := 0;
      a2 := 0;
      c := 0;
      ind := 0;
      Count := 0;
      Source_Len := Length(source);
      while Count < Source_Len do
      begin
        if Len >= $2710 then
          break;
        ind := ord(source[Count+1]);
        ind := ind shr (c+2);
        a1 := ind or a2;
        a1 := a1 and $3f;
        ind := ord(source[Count+1]);
        ind := ind shl (8-(c+2));
        ind := ind shr 2;
        a2 := ind and $3f;
        inc(c,2);
        if c >= 6 then
        begin
          if Len >= $270f then
          begin
            Encode_Str := Encode_Str + chr(a1 + $3c);
            inc(Len);
          end
          else
          begin
            Encode_Str := Encode_Str + chr(a1 + $3c);
            Encode_Str := Encode_Str + chr(a2 + $3c);
            Inc(Len,2);
          end;
          c := 0;
          a2 := 0;
        end
        else
        begin
          Encode_Str := Encode_Str + chr(a1 + $3c);
          Inc(Len);
        end;
        inc(Count);
      end;
      if c > 0 then
      begin
        Encode_Str := Encode_Str + chr(a2 + $3c);
        Inc(Len);
      end;
      SetLength(Encode_Str,Len);
      Result := Encode_Str;
    end;
    function Decode(source : string):string;  //解密
    var
      Source_Len,Len : integer;
      Count,c1,c2 : integer;
      code : array[0..7] of byte;
      a1,a2 : byte;
      ind : dword;
      Decode_Str : string;
      label L1,L2;
    begin
      Result := '';
      Decode_Str := '';
      code[2] := $fc;
      code[4] := $f0;
      code[6] := $c0;
      Len := 0;
      a1 := 0;
      a2 := 0;
      c1 := 2;
      c2 := 0;
      ind := 0;
      Count := 0;
      Source_Len := Length(source);
      while (Count < Source_Len) do
      begin
        if(ord(Source[Count+1]) - $3c) < 0 then
        begin
          Decode_Str := Decode_Str + Source[Count+1];
          inc(Len);
          inc(Count);
          a1 := 0;
          a2 := 0;
          c1 := 2;
          c2 := 0;
          ind := 0;
          Continue;
          //break;
        end;
        a1 := ord(Source[Count+1]) - $3c;
        if Len >= Source_Len then
        begin
          break;
        end;
        if (c2 + 6) < 8 then
        begin
          goto L2;
        end;
        ind := a1 and $3f;
        ind := ind shr (6-c1);
        Decode_Str := Decode_Str + chr(ind or a2);
        Inc(Len);
        c2 := 0;
        if c1 >= 6 then
        begin
          c1 := 2;
          goto L1;
        end;
        inc(c1,2);
        L2 :a2 := a1 shl c1;
        a2 := a2 and code[c1];
        c2 := c2 + (8 - c1);
        L1 :inc(count);
      end;
      SetLength(Decode_Str,Len);
      Result := Decode_Str;
    end;
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
        s:string;
        i:integer;
    begin
       s:=Edit1.Text;
       for   i:=1   to   length(s)   do
       begin
         s[i]:=chr( ord(s[i])   xor   250);
       end;
        Label1.Caption:=s;
    end;
    加密和解密一样的函数。
    /////////////////////////////////////////
    procedure TForm1.Button2Click(Sender: TObject);
    var
        s:string;
        i:integer;
    begin
        s:=Label1.Caption;
        for i:=1 to length(s) do
        begin
            s[i]:=chr(ord(s[i]) xor 250);
        end;
        Label2.Caption:=s;
    end;
      

  5.   

    第二个算发,由于用的是移位运算再强制转换,char类型,会造成位的丢失,不能还原。
      

  6.   

    s[i]:=chr(ord(s[i]) xor 250);如何把上句代码用VBSCRIPT脚本语言实现???
      

  7.   

    VBSCRIPT不熟,不就是把s的第i个字符取出,转换成整数,再和250异或算一下。很困难么?
      

  8.   

    s[i]:=chr(Asc(s[i]) xor 250);
      

  9.   


    〈%dim sequence
    sequence=Request("sequence")
    for i=0 to len(sequence)-1) 
      sequence(i)=chr(Asc(sequence(i) xor 250);
    next
    %〉 
    请问这么做错在哪里???
      

  10.   

    错的地方太多了for i=0 to len(sequence)-1) '多了一个)
     sequence(i)=chr(Asc(sequence(i) xor 250);  '多了一个;