BASE64怎么解密呢(重金)(300分)

  • 主题发起人 主题发起人 ivy1982
  • 开始时间 开始时间
I

ivy1982

Unregistered / Unconfirmed
GUEST, unregistred user!
BASE64
怎么解密呢

(重金)不够可以再加
急等
 
或许不是加密啊。是不是Internet编码啊。
 
to 蓝叶菱
好像不是
 
我指是XML编码,我的WEB的的图像,编码后都是什么QM=,
要么就是BASE64了。
 
to 蓝叶菱
是BASE64
不过怎么解密呢
另开帖给你300分
http://delphibbs.com/delphibbs/dispq.asp?lid=3483492
 
加密前 加密后
1 MQ==
4 NA==

是用什么加密的

(重金)不够可以再加
急等
 
脚本说明:

把如下代码加入<body>区域中
<script language=javascript>
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var base64DecodeChars = new Array(
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);

function base64encode(str) {
var out, i, len;
var c1, c2, c3;

len = str.length;
i = 0;
out = "";
while(i < len) {
c1 = str.charCodeAt(i++) & 0xff;
if(i == len)
{
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt((c1 & 0x3) << 4);
out += "==";
break;
}
c2 = str.charCodeAt(i++);
if(i == len)
{
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
out += base64EncodeChars.charAt((c2 & 0xF) << 2);
out += "=";
break;
}
c3 = str.charCodeAt(i++);
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
out += base64EncodeChars.charAt(c3 & 0x3F);
}
return out;
}

function base64decode(str) {
var c1, c2, c3, c4;
var i, len, out;

len = str.length;
i = 0;
out = "";
while(i < len) {
/* c1 */
do {
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
} while(i < len && c1 == -1);
if(c1 == -1)
break;

/* c2 */
do {
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
} while(i < len && c2 == -1);
if(c2 == -1)
break;

out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));

/* c3 */
do {
c3 = str.charCodeAt(i++) & 0xff;
if(c3 == 61)
return out;
c3 = base64DecodeChars[c3];
} while(i < len && c3 == -1);
if(c3 == -1)
break;

out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));

/* c4 */
do {
c4 = str.charCodeAt(i++) & 0xff;
if(c4 == 61)
return out;
c4 = base64DecodeChars[c4];
} while(i < len && c4 == -1);
if(c4 == -1)
break;
out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
}
return out;
}

function utf16to8(str) {
var out, i, len, c;

out = "";
len = str.length;
for(i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i);
} else if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
}
}
return out;
}

function utf8to16(str) {
var out, i, len, c;
var char2, char3;

out = "";
len = str.length;
i = 0;
while(i < len) {
c = str.charCodeAt(i++);
switch(c >> 4)
{
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
// 0xxxxxxx
out += str.charAt(i-1);
break;
case 12: case 13:
// 110x xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
char3 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x0F) << 12) |
((char2 & 0x3F) << 6) |
((char3 & 0x3F) << 0));
break;
}
}

return out;
}


function doit() {
var f = document.f
f.output.value = base64encode(utf16to8(f.source.value))
f.decode.value = utf8to16(base64decode(f.output.value))
}
</script>
<H1>Base64</H1>
<FORM NAME="f">
原码<BR>
<TEXTAREA NAME="source" ROWS=4 COLS=60 WRAP="soft"></TEXTAREA><BR><BR>
Base64 encode<BR>
<TEXTAREA NAME="output" ROWS=4 COLS=60 WRAP="soft"></TEXTAREA><BR><BR>
Base64 decode<BR>
<TEXTAREA NAME="decode" ROWS=4 COLS=60 WRAP="soft"></TEXTAREA><BR><BR>
<INPUT TYPE=BUTTON VALUE="转换" ONCLICK="doit()">
</FORM>
 
http://www.jzzy.com/display.asp?id=1650
 
你下载一个BASE64单元了,自己先做试试看,
我以前做过加密,没有做过解密。后来就改用MD5了。
1。BASE64算法,你可以到WWW.DELPHIBOX.COM下载单元看看。不难的。
2。要么你使用解密软件,好像能够解密RAR的软件包,有对BASE64的解密工具。。

其他我就不知道了。
 
unit Base64Fun;

interface

uses
Windows, SysUtils, DateUtils, ShlObj, ActiveX, ComObj, Registry;

const
BaseTable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; //这是Base64转换用的常量字符

function Replacing(S, source, target: string; times: Integer): string;
function DeleteSubString(S, substring: string; Times: Integer; CaseSensivte: Boolean): string;
function EncodeBase64(Source:string):string;
function DecodeBase64(Source:string):string;
function GetFileSize(filename:string):integer; //用findfrist方法得到一个文件的大小
function GetComputerName: string;

var ComputerName:string;

implementation

function Replacing(S, Source, Target: string; Times: Integer): string;
var
Site, StrLen, i: integer;
begin
if Source <> Target then begin
StrLen := Length(Source);
i := Times;
while (i >= 0) and (Pos(Source, S)>0) do begin
Site := Pos(Source, S);
Delete(S, Site, StrLen);
Insert(Target, S, Site);
dec(i);
end;
end;
Result := S;
end;

function DeleteSubString(S, substring: string; Times: Integer; CaseSensivte: Boolean): string;
var
CharPos, l, i: Integer;
begin
l := Length(SubString);
i := Times;
while (i>0) do begin
if CaseSensivte then
CharPos := Pos(SubString, S)
else
CharPos := Pos(UpperCase(SubString), UpperCase(S));

if CharPos>0 then begin
Delete(S, CharPos, l);
dec(i);
end
else break;
end;
Result := S;
end;

function EncodeBase64(Source:string):string;
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;

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:=Pos(Source[1+i*4],BaseTable)-1;
x2:=Pos(Source[2+i*4],BaseTable)-1;
x3:=Pos(Source[3+i*4],BaseTable)-1;
x4:=Pos(Source[4+i*4],BaseTable)-1;
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 GetFileSize(filename:string):integer;
var
sr: TSearchRec;
begin
result:=-1;
if FindFirst(filename, faAnyFile-faDirectory, sr) = 0 then
result:=sr.Size;
end;

function GetComputerName: string;
var
buffer: array[0..MAX_COMPUTERNAME_LENGTH + 1] of Char;
Size: Cardinal;
begin
Size := MAX_COMPUTERNAME_LENGTH + 1;
Windows.GetComputerName(@buffer, Size);
Result := StrPas(buffer);
end;

end.
 
function StrTobase64( Buf: string ): string;
var
// B3 : string[3];
i : integer;
x1, x2, x3, x4: byte;
PadCount : integer;
begin
PadCount := 0;

// we need at least 3 input bytes...
while length( Buf ) < 3 do
begin
Buf := Buf + #0;
inc( PadCount );
end;

// ...and all input must be an even multiple of 3
while ( length( Buf ) mod 3 ) <> 0 do
begin
Buf := Buf + #0; // if not, zero padding is added
inc( PadCount );
end;

Result := '';
i := 1;

// process 3-byte blocks or 24 bits
while i <= length( Buf ) - 2 do
begin
// each 3 input bytes are transformed into 4 index values
// in the range of 0..63, by taking 6 bits each step

// 6 high bytes of first char
x1 := ( Ord( Buf ) shr 2 ) and $3F;

// 2 low bytes of first char + 4 high bytes of second char
x2 := ( ( Ord( Buf ) shl 4 ) and $3F )
or Ord( Buf[i + 1] ) shr 4;

// 4 low bytes of second char + 2 high bytes of third char
x3 := ( ( Ord( Buf[i + 1] ) shl 2 ) and $3F )
or Ord( Buf[i + 2] ) shr 6;

// 6 low bytes of third char
x4 := Ord( Buf[i + 2] ) and $3F;

// the index values point into the code array
Result := Result
+ Base64Code[x1 + 1]
+ Base64Code[x2 + 1]
+ Base64Code[x3 + 1]
+ Base64Code[x4 + 1];
inc( i, 3 );
end;

// if needed, finish by forcing padding chars ('=')
// at end of string
if PadCount > 0 then
for i := Length( Result ) downto 1 do
begin
Result := Pad;
dec( PadCount );
if PadCount = 0 then BREAK;
end;

end;

//*****************************************************************************
// helper : given a char, returns the index in code table
function Char2IDx( c: char ): byte;
var
i : integer;
begin
for i := 1 to Length( Base64Code ) do
if Base64Code = c then
begin
Result := pred( i );
EXIT;
end;
Result := Ord( Pad );
end;

//*****************************************************************************
function Base64ToStr( B64: string ): string;
var
i,
PadCount : integer;
Block : string[3];
x1, x2, x3 : byte;
begin

// input _must_ be at least 4 chars long,
// or multiple of 4 chars
if ( Length( B64 ) < 4 )
or ( Length( B64 ) mod 4 <> 0 ) then
raise EBase64Error.Create( 'Base64ToStr: illegal input length!' );
//
PadCount := 0;
i := Length( B64 );
// count padding chars, if any
while (B64 = Pad)
and (i > 0 ) do
begin
inc( PadCount );
dec( i );
end;
//
Result := '';
i := 1;
SetLength( Block, 3 );
while i <= Length( B64 ) - 3 do
begin
// reverse process of above
x1 := ( Char2Idx( B64 ) shl 2 ) or ( Char2IDx( B64[i + 1] ) shr 4 );
Result := Result + Chr( x1 );
x2 := ( Char2Idx( B64[i + 1] ) shl 4 ) or ( Char2IDx( B64[i + 2] ) shr 2 );
Result := Result + Chr( x2 );
x3 := ( Char2Idx( B64[i + 2] ) shl 6 ) or ( Char2IDx( B64[i + 3] ) );
Result := Result + Chr( x3 );
inc( i, 4 );
end;

// delete padding, if any
while PadCount > 0 do
begin
Delete( Result, Length( Result ), 1 );
dec( PadCount );
end;

end;
 
不是加密啊,就是编码而已,没有密钥的。

1 MQ== 2 Mg== 4 NA== 8 OA== 12 MTI=
a YQ== b Yg== A QQ== Z Wg== aZ YVo=

const
CharTable='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= $()[]{},;:-_/*"'''#9#10#13#0;

function TableFind(Value: Char; Table: PChar; Len: Integer): Integer; assembler;
asm // Utility for TStringFormat_XXXXX
PUSH EDI
MOV EDI,EDX
REPNE SCASB
MOV EAX,0
JNE @@1
MOV EAX,EDI
SUB EAX,EDX
@@1: DEC EAX
POP EDI
end;

function MIME64ToStr(Value: PChar; Len: Integer): String;
var
B: Cardinal;
J,I: Integer;
S,D,L,T: PChar;
begin
Result := '';
if Value = nil then Exit;
if Len < 0 then Len := Length(Value);
if Len = 0 then Exit;
SetLength(Result, Len);
Move(PChar(Value)^, PChar(Result)^, Len);
T := CharTable;
while Len mod 4 <> 0 do
begin
Result := Result + T[64];
Inc(Len);
end;
D := PChar(Result);
S := D;
L := S + Len;
Len := Len * 3 div 4;
while Len > 0 do
begin
B := 0;
J := 4;
while (J > 0) and (S <= L) do
begin
I := TableFind(S^, T, 65);
if I >= 0 then
begin
B := B shl 6;
if I >= 64 then Dec(Len) else B := B or Byte(I);
Dec(J);
end;
Inc(S);
end;
J := 2;
repeat
D[J] := Char(B);
B := B shr 8;
Dec(J);
until J < 0;
if Len > 3 then Inc(D, 3) else Inc(D, Len);
Dec(Len, 3);
end;
SetLength(Result, D - PChar(Result));
end;

function StrToMIME64(Value: PChar; Len: Integer): String;
var
B: Cardinal;
I: Integer;
D,T: PChar;
begin
Result := '';
if Value = nil then Exit;
if Len < 0 then Len := StrLen(Value);
if Len = 0 then Exit;
SetLength(Result, Len * 4 div 3 + 4);
D := PChar(Result);
T := CharTable;
while Len > 0 do
begin
B := 0;
for I := 0 to 2 do
begin
B := B shl 8;
if Len > 0 then
begin
B := B or Byte(Value^);
Inc(Value);
end;
Dec(Len);
end;
for I := 3 downto 0 do
begin
if Len < 0 then
begin
D := T[64];
Inc(Len);
end else D := T[B and $3F];
B := B shr 6;
end;
Inc(D, 4);
end;
SetLength(Result, D - PChar(Result));
end;


//使用范例:
procedure TForm1.Button1Click(Sender: TObject);
var
mstr,CodeStr:String;
begin
mstr:='4'; //原始字符串
CodeStr:=StrToMIME64(@mstr[1],Length(mstr)); //编码后字符串
ShowMessage(CodeStr);
ShowMessage(MIME64ToStr(@CodeStr[1],Length(CodeStr))); //编码还原
end;
 
其实解码AES,BASE64,主要就是猜这个 mstr,
很难猜得。。
你看其他工具了。。。
 
多人接受答案了。
 
后退
顶部