各位兄弟姐妹有沒有delphi的MD5演算法的denmo,小弟在專案中遇到棘手就是客戶那邊的要求用MD5加密,而且要用密鑰的,但是我網上找了很多資料都沒見到帶密鑰引數的演算法
uj5u.com熱心網友回復:
MD5 是破壞性加密,加密時是不存在密鑰的。自然也是不可逆的,但是也有一種方法是人工添加密鑰混合進明文中實作,雖然也是不可逆的,但是多了所謂“密鑰”這一特性:
比如: 明文是“ABCDEFG” ,密鑰是“ABC123”
那么用MD5加密前把 明文+密鑰 “ABCDEFGABC123” 后再用 MD5加密。
uj5u.com熱心網友回復:
md5是不可逆演算法,沒有“密鑰”這一說法。uj5u.com熱心網友回復:
MD5是Hashuj5u.com熱心網友回復:
嚴謹的說md5不是加密演算法,而是摘要函式,根據給定的一串值得到一串與給定值唯一匹配的摘要串,且演算法是不可逆的。這個演算法是公開的,網上隨便搜搜都有。更沒有密鑰一說。
uj5u.com熱心網友回復:
網上有實體呀,分太少了呀幫你頂頂
uj5u.com熱心網友回復:
等待等分漲了,為你撰寫一個實體
uj5u.com熱心網友回復:
樓上的兄弟,我已經加分了,能寫個實體發給我嗎?等著急用。。。。uj5u.com熱心網友回復:
路過的大蝦們請拔刀相助吧,已經加到最高分了uj5u.com熱心網友回復:
unit Unit4;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
const
MaxBufSize = 16384;
MD5Version = 102;
CopyRight : String = 'MD5 Message-Digest (c) 97-98 F. Piette V1.02';
type
TMD5Context = record
State: array[0..3] of LongInt;
Count: array[0..1] of LongInt;
case Integer of
0: (BufChar: array[0..63] of Byte);
1: (BufLong: array[0..15] of LongInt);
end;
TMD5Digest = array[0..15] of Char;
PMD5Buffer = ^TMD5Buffer;
TMD5Buffer = array[0..(MaxBufSize - 1)] of Char;
TForm4 = class(TForm)
BitBtn1: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure MD5Init(var MD5Context: TMD5Context);
procedure MD5Update(var MD5Context: TMD5Context;
const Data;
Len: Integer);
procedure MD5Transform(var Buf: array of LongInt;
const Data: array of LongInt);
procedure MD5UpdateBuffer(var MD5Context: TMD5Context;
Buffer: Pointer;
BufSize: Integer);
procedure MD5Final(var Digest: TMD5Digest; var MD5Context: TMD5Context);
function GetMD5(Buffer: Pointer; BufSize: Integer): string;
function StrMD5(Buffer : String): string;
var
Form4: TForm4;
implementation
{$R *.dfm}
{ MD5 initialization. Begins an MD5 operation, writing a new context. }
procedure MD5Init(var MD5Context: TMD5Context);
begin
FillChar(MD5Context, SizeOf(TMD5Context), #0);
with MD5Context do begin
{ Load magic initialization constants. }
State[0] := LongInt($67452301);
State[1] := LongInt($EFCDAB89);
State[2] := LongInt($98BADCFE);
State[3] := LongInt($10325476);
end
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ MD5 block update operation. Continues an MD5 message-digest operation, }
{ processing another message block, and updating the context. }
procedure MD5Update(
var MD5Context: TMD5Context; { Context }
const Data; { Input block }
Len: Integer); { Length of input block }
type
TByteArray = array[0..0] of Byte;
var
Index: Word;
T: LongInt;
begin
with MD5Context do begin
T := Count[0];
Inc(Count[0], LongInt(Len) shl 3);
if Count[0] < T then
Inc(Count[1]);
Inc(Count[1], Len shr 29);
T := (T shr 3) and $3F;
Index := 0;
if T <> 0 then begin
Index := T;
T := 64 - T;
if Len < T then begin
Move(Data, BufChar[Index], Len);
Exit;
end;
Move(Data, BufChar[Index], T);
MD5Transform(State, BufLong);
Dec(Len, T);
Index := T; { Wolfgang Klein, 05/06/99 }
end;
while Len >= 64 do begin
Move(TByteArray(Data)[Index], BufChar, 64);
MD5Transform(State, BufLong);
Inc(Index, 64);
Dec(Len, 64);
end;
Move(TByteArray(Data)[Index], BufChar, Len);
end
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ MD5 finalization. Ends an MD5 message-digest operation, writing the message }
{ digest and zeroizing the context. }
procedure MD5Final(var Digest: TMD5Digest; var MD5Context: TMD5Context);
var
Cnt : Word;
P : Byte;
begin
with MD5Context do begin
Cnt := (Count[0] shr 3) and $3F;
P := Cnt;
BufChar[P] := $80;
Inc(P);
Cnt := 64 - 1 - Cnt;
if Cnt < 8 then begin
FillChar(BufChar[P], Cnt, #0);
MD5Transform(State, BufLong);
FillChar(BufChar, 56, #0);
end
else
FillChar(BufChar[P], Cnt - 8, #0);
BufLong[14] := Count[0];
BufLong[15] := Count[1];
MD5Transform(State, BufLong);
Move(State, Digest, 16)
end;
FillChar(MD5Context, SizeOf(TMD5Context), #0)
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ MD5 basic transformation. Transforms state based on block. }
procedure MD5Transform(
var Buf: array of LongInt;
const Data: array of LongInt);
var
A, B, C, D: LongInt;
procedure Round1(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);
begin
Inc(W, (Z xor (X and (Y xor Z))) + Data);
W := (W shl S) or (W shr (32 - S));
Inc(W, X)
end;
procedure Round2(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);
begin
Inc(W, (Y xor (Z and (X xor Y))) + Data);
W := (W shl S) or (W shr (32 - S));
Inc(W, X)
end;
procedure Round3(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);
begin
Inc(W, (X xor Y xor Z) + Data);
W := (W shl S) or (W shr (32 - S));
Inc(W, X)
end;
procedure Round4(var W: LongInt; X, Y, Z, Data: LongInt; S: Byte);
begin
Inc(W, (Y xor (X or not Z)) + Data);
W := (W shl S) or (W shr (32 - S));
Inc(W, X)
end;
begin
A := Buf[0];
B := Buf[1];
C := Buf[2];
D := Buf[3];
Round1(A, B, C, D, Data[ 0] + LongInt($d76aa478), 7);
Round1(D, A, B, C, Data[ 1] + LongInt($e8c7b756), 12);
Round1(C, D, A, B, Data[ 2] + LongInt($242070db), 17);
Round1(B, C, D, A, Data[ 3] + LongInt($c1bdceee), 22);
Round1(A, B, C, D, Data[ 4] + LongInt($f57c0faf), 7);
Round1(D, A, B, C, Data[ 5] + LongInt($4787c62a), 12);
Round1(C, D, A, B, Data[ 6] + LongInt($a8304613), 17);
Round1(B, C, D, A, Data[ 7] + LongInt($fd469501), 22);
Round1(A, B, C, D, Data[ 8] + LongInt($698098d8), 7);
Round1(D, A, B, C, Data[ 9] + LongInt($8b44f7af), 12);
Round1(C, D, A, B, Data[10] + LongInt($ffff5bb1), 17);
Round1(B, C, D, A, Data[11] + LongInt($895cd7be), 22);
Round1(A, B, C, D, Data[12] + LongInt($6b901122), 7);
Round1(D, A, B, C, Data[13] + LongInt($fd987193), 12);
Round1(C, D, A, B, Data[14] + LongInt($a679438e), 17);
Round1(B, C, D, A, Data[15] + LongInt($49b40821), 22);
Round2(A, B, C, D, Data[ 1] + LongInt($f61e2562), 5);
Round2(D, A, B, C, Data[ 6] + LongInt($c040b340), 9);
Round2(C, D, A, B, Data[11] + LongInt($265e5a51), 14);
Round2(B, C, D, A, Data[ 0] + LongInt($e9b6c7aa), 20);
Round2(A, B, C, D, Data[ 5] + LongInt($d62f105d), 5);
Round2(D, A, B, C, Data[10] + LongInt($02441453), 9);
Round2(C, D, A, B, Data[15] + LongInt($d8a1e681), 14);
Round2(B, C, D, A, Data[ 4] + LongInt($e7d3fbc8), 20);
Round2(A, B, C, D, Data[ 9] + LongInt($21e1cde6), 5);
Round2(D, A, B, C, Data[14] + LongInt($c33707d6), 9);
Round2(C, D, A, B, Data[ 3] + LongInt($f4d50d87), 14);
Round2(B, C, D, A, Data[ 8] + LongInt($455a14ed), 20);
Round2(A, B, C, D, Data[13] + LongInt($a9e3e905), 5);
Round2(D, A, B, C, Data[ 2] + LongInt($fcefa3f8), 9);
Round2(C, D, A, B, Data[ 7] + LongInt($676f02d9), 14);
Round2(B, C, D, A, Data[12] + LongInt($8d2a4c8a), 20);
Round3(A, B, C, D, Data[ 5] + LongInt($fffa3942), 4);
Round3(D, A, B, C, Data[ 8] + LongInt($8771f681), 11);
Round3(C, D, A, B, Data[11] + LongInt($6d9d6122), 16);
Round3(B, C, D, A, Data[14] + LongInt($fde5380c), 23);
Round3(A, B, C, D, Data[ 1] + LongInt($a4beea44), 4);
Round3(D, A, B, C, Data[ 4] + LongInt($4bdecfa9), 11);
Round3(C, D, A, B, Data[ 7] + LongInt($f6bb4b60), 16);
Round3(B, C, D, A, Data[10] + LongInt($bebfbc70), 23);
Round3(A, B, C, D, Data[13] + LongInt($289b7ec6), 4);
Round3(D, A, B, C, Data[ 0] + LongInt($eaa127fa), 11);
Round3(C, D, A, B, Data[ 3] + LongInt($d4ef3085), 16);
Round3(B, C, D, A, Data[ 6] + LongInt($04881d05), 23);
Round3(A, B, C, D, Data[ 9] + LongInt($d9d4d039), 4);
Round3(D, A, B, C, Data[12] + LongInt($e6db99e5), 11);
Round3(C, D, A, B, Data[15] + LongInt($1fa27cf8), 16);
Round3(B, C, D, A, Data[ 2] + LongInt($c4ac5665), 23);
Round4(A, B, C, D, Data[ 0] + LongInt($f4292244), 6);
Round4(D, A, B, C, Data[ 7] + LongInt($432aff97), 10);
Round4(C, D, A, B, Data[14] + LongInt($ab9423a7), 15);
Round4(B, C, D, A, Data[ 5] + LongInt($fc93a039), 21);
Round4(A, B, C, D, Data[12] + LongInt($655b59c3), 6);
Round4(D, A, B, C, Data[ 3] + LongInt($8f0ccc92), 10);
Round4(C, D, A, B, Data[10] + LongInt($ffeff47d), 15);
Round4(B, C, D, A, Data[ 1] + LongInt($85845dd1), 21);
Round4(A, B, C, D, Data[ 8] + LongInt($6fa87e4f), 6);
Round4(D, A, B, C, Data[15] + LongInt($fe2ce6e0), 10);
Round4(C, D, A, B, Data[ 6] + LongInt($a3014314), 15);
Round4(B, C, D, A, Data[13] + LongInt($4e0811a1), 21);
Round4(A, B, C, D, Data[ 4] + LongInt($f7537e82), 6);
Round4(D, A, B, C, Data[11] + LongInt($bd3af235), 10);
Round4(C, D, A, B, Data[ 2] + LongInt($2ad7d2bb), 15);
Round4(B, C, D, A, Data[ 9] + LongInt($eb86d391), 21);
Inc(Buf[0], A);
Inc(Buf[1], B);
Inc(Buf[2], C);
Inc(Buf[3], D);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
uj5u.com熱心網友回復:
unit Unit4;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
const
MaxBufSize = 16384;
MD5Version = 102;
CopyRight : String = 'MD5 Message-Digest (c) 97-98 F. Piette V1.02';
type
TMD5Context = record
State: array[0..3] of LongInt;
Count: array[0..1] of LongInt;
case Integer of
0: (BufChar: array[0..63] of Byte);
1: (BufLong: array[0..15] of LongInt);
end;
TMD5Digest = array[0..15] of Char;
PMD5Buffer = ^TMD5Buffer;
TMD5Buffer = array[0..(MaxBufSize - 1)] of Char;
TForm4 = class(TForm)
BitBtn1: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure MD5Init(var MD5Context: TMD5Context);
procedure MD5Update(var MD5Context: TMD5Context;
const Data;
Len: Integer);
procedure MD5Transform(var Buf: array of LongInt;
const Data: array of LongInt);
procedure MD5UpdateBuffer(var MD5Context: TMD5Context;
Buffer: Pointer;
BufSize: Integer);
procedure MD5Final(var Digest: TMD5Digest; var MD5Context: TMD5Context);
function GetMD5(Buffer: Pointer; BufSize: Integer): string;
function StrMD5(Buffer : String): string;
var
Form4: TForm4;
implementation
{$R *.dfm}
{ MD5 initialization. Begins an MD5 operation, writing a new context. }
procedure MD5Init(var MD5Context: TMD5Context);
begin
FillChar(MD5Context, SizeOf(TMD5Context), #0);
with MD5Context do begin
{ Load magic initialization constants. }
State[0] := LongInt($67452301);
State[1] := LongInt($EFCDAB89);
State[2] := LongInt($98BADCFE);
State[3] := LongInt($10325476);
end
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ MD5 block update operation. Continues an MD5 message-digest operation, }
{ processing another message block, and updating the context. }
procedure MD5Update(
var MD5Context: TMD5Context; { Context }
const Data; { Input block }
Len: Integer); { Length of input block }
type
TByteArray = array[0..0] of Byte;
var
Index: Word;
T: LongInt;
begin
with MD5Context do begin
T := Count[0];
Inc(Count[0], LongInt(Len) shl 3);
if Count[0] < T then
Inc(Count[1]);
Inc(Count[1], Len shr 29);
T := (T shr 3) and $3F;
Index := 0;
if T <> 0 then begin
Index := T;
T := 64 - T;
if Len < T then begin
Move(Data, BufChar[Index], Len);
Exit;
end;
Move(Data, BufChar[Index], T);
MD5Transform(State, BufLong);
Dec(Len, T);
Index := T; { Wolfgang Klein, 05/06/99 }
end;
while Len >= 64 do begin
Move(TByteArray(Data)[Index], BufChar, 64);
MD5Transform(State, BufLong);
Inc(Index, 64);
Dec(Len, 64);
end;
Move(TByteArray(Data)[Index], BufChar, Len);
end
end;
uj5u.com熱心網友回復:
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}procedure MD5UpdateBuffer(
var MD5Context: TMD5Context;
Buffer: Pointer;
BufSize: Integer);
var
BufTmp : PMD5Buffer;
BufPtr : PChar;
Bytes : Word;
begin
New(BufTmp);
BufPtr := Buffer;
try
repeat
if BufSize > MaxBufSize then
Bytes := MaxBufSize
else
Bytes := BufSize;
Move(BufPtr^, BufTmp^, Bytes);
Inc(BufPtr, Bytes);
Dec(BufSize, Bytes);
if Bytes > 0 then
MD5Update(MD5Context, BufTmp^, Bytes);
until Bytes < MaxBufSize;
finally
Dispose(BufTmp);
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function GetMD5(Buffer: Pointer; BufSize: Integer): string;
var
I : Integer;
MD5Digest : TMD5Digest;
MD5Context : TMD5Context;
begin
for I := 0 to 15 do
Byte(MD5Digest[I]) := I + 1;
MD5Init(MD5Context);
MD5UpdateBuffer(MD5Context, Buffer, BufSize);
MD5Final(MD5Digest, MD5Context);
Result := '';
for I := 0 to 15 do
Result := Result + IntToHex(Byte(MD5Digest[I]), 2);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function StrMD5(Buffer : String): string;
begin
Result := GetMD5(@Buffer[1], Length(Buffer));
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
var
vKey : string;
begin
vKey := '123456';
Edit2.Text :=StrMd5(Edit1.Text +vKey);
end;
end.
uj5u.com熱心網友回復:
要說密鑰這東西的話去找AES之類的加密吧uj5u.com熱心網友回復:
MD5是不可逆的,木有密鑰,一般是防止資訊篡改。所謂的“密鑰”,可能是在某地方加上雙方約定好的字串而已。
uj5u.com熱心網友回復:
關注一下我的QQ,我傳個實體給你
uj5u.com熱心網友回復:
樓上的兄弟:你的QQ多少啊,上面的的兄弟先謝了,你們說的代碼都試過了,加密后都沒得到跟客戶一樣的密文,舉個例子:明文:1051006212012050200063281110510062120120502000632801105100621201205020006327911051006212012050200063278210510062120120502000632771
密鑰:Picc37mu63ht38mw
客戶那邊MD5加密后得到密文是:4577c0b6b3364fb097ecd16293f157d6
不知道他那邊是怎么算出這個密文的
uj5u.com熱心網友回復:
我已發信給你了,請查收uj5u.com熱心網友回復:
MD5是摘要演算法,是不可逆的!uj5u.com熱心網友回復:
樓主呀,MD5還沒有搞定呀uj5u.com熱心網友回復:

uj5u.com熱心網友回復:
帶密鑰的是 HMAC-MD5,密鑰是鹽uj5u.com熱心網友回復:
indy里有md5的實作uj5u.com熱心網友回復:
借鑒一下,正好想實作用戶登錄密碼加密保存,不知怎么實作呢。uj5u.com熱心網友回復:
大神,幫我也發一份吧,急急急![email protected]uj5u.com熱心網友回復:
/** 生成簽名
* @param method HTTP請求方法 "get" / "post" //引數1:請求方式的字串值
* @param url_path CGI名字, //引數2:api的相對URL的字串值
* @param params URL請求引數 //引數3:由request的請求名和值,構成的hashmap資料型別值
* @param secret 密鑰 //引數4:用戶網站的appkey的字串值
* @return 簽名值 //回傳值,對請求值進行hmac-sha1加密演算法的計算回傳值。
* @throws OpensnsException 不支持指定編碼以及不支持指定的加密方法時拋出例外。
*/
private String makeSign(String method, String url_path, HashMap<String, String> params, String secret) throws OpenApiException {
String sig = "";
try {
Mac mac = Mac.getInstance("HmacSHA1"); //1 得到一個是hmacsha1的mac物件
SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(charset), mac.getAlgorithm()); //2 創建secretKey物件
mac.init(secretKey); //3 用secretkey物件,初始化mac物件。
String mk = makeSource(method, url_path, params); //4 輸入method、url_path,parms引數,得到源名碼
System.out.println(mk);
byte[] hash = mac.doFinal(mk.getBytes(charset)); //5 用mac對源名碼加密,得到byte陣列
sig = new String(Base64Coder.encode(hash)); //6 encode編碼,然后轉化為string輸出值
// sig = encodeUrl(sig);
} catch (Exception e) {
throw new OpenApiException(OpenApiException.MAKE_SIGNATURE_ERROR, e);
}
return sig;
}
輸入post/get 的string值、相對api的url string值、hashmap方式的request值、appkey的string值,經過hmac演算法,得到計算的密碼值。
源名碼=源明碼
上面是拍拍網的api訪問的java的demo,有否delphi版的演算法例子。
uj5u.com熱心網友回復:
unit Unit3;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,
IdHashMessageDigest, HTTPApp, IdHMACSHA1, IdCoderMIME, DateUtils;
type
TForm3 = class(TForm)
BitBtn1: TBitBtn;
Memo1: TMemo;
procedure BitBtn1Click(Sender: TObject);
procedure Memo1Change(Sender: TObject);
private
{ Private declarations }
function Base64Encode(const Input: TBytes): string;
function EncryptHMACSha1(Input,AKey:AnsiString): TBytes;
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.BitBtn1Click(Sender: TObject);
var
sHttpMethod: AnsiString;
sRequestURL: AnsiString;
sRequestParameter: AnsiString;
sAppSecret: AnsiString;
sSignatureBaseString: AnsiString;
sMD5: TIdHashMessageDigest5;
begin
sMD5 := TIdHashMessageDigest5.Create;
sAppSecret := '4b50186d12987f405b17bc38c9b99b0a&'; //密鑰
sHttpMethod := 'GET';
sRequestURL := 'http://open.t.qq.com/cgi-bin/request_token';
sRequestParameter := 'oauth_callback=null&oauth_consumer_key=8*******9&oauth_nonce=';
sRequestParameter := sRequestParameter + sMD5.HashStringAsHex(IntToStr(Random(10000)), nil); //隨機32位數
sRequestParameter := sRequestParameter + '&oauth_signature_method=HMAC-SHA1&oauth_timestamp=';
sRequestParameter := sRequestParameter + FloatToStr(DateTimeToUnix(Now()-1/3)); //時間戳
sRequestParameter := sRequestParameter + '&oauth_version=1.0';
sSignatureBaseString := HTTPEncode(sHttpMethod) + '&' + HTTPEncode(sRequestURL) + '&' + HTTPEncode(sRequestParameter);
Memo1.Text := Base64Encode(EncryptHMACSha1(sSignatureBaseString, sAppSecret));
sMD5.Free;
end;
//兩個函式 Base64Encode,EncryptHMACSha1;
//HMACSha1演算法
function TForm3.EncryptHMACSha1(Input,AKey:AnsiString): TBytes;
var Key: TBytes;
begin
with TIdHMACSHA1.Create do
try
Key := BytesOf(AKey);
Result := HashValue(BytesOf(Input));
finally
Free;
end;
end;
procedure TForm3.Memo1Change(Sender: TObject);
begin
end;
//Base64編碼
function TForm3.Base64Encode(const Input: TBytes): string;
begin
Result := TIdEncoderMIME.EncodeBytes(Input);
end;
end.
uj5u.com熱心網友回復:
OAuth的精髓
DM5是無密鑰的加密演算法,輸入明文,得到密碼
如果黑客截獲URL值,里面包含網店的id、密碼、spid等值,
就可以利用這些值構造另外一個URL,
再用DM5演算法得到sign值,這樣網店的介面也對黑客開放了。
所以MD5加密簽權方法,讓黑客有機會進入網店后臺亂搞,比如修改價格、修改商品等
黑客可以用木馬等程式,截獲API的URL
而OAuth方法,是采用hmac-sha1演算法,加密時必須OAuthKey(密鑰值),
這個值是商家系統在平臺注冊商家系統時留在平臺里的,把明文加密成sign值時,
必需要提供OAuthKey值才可以加密成密碼。
而在URL只是包含網店的key、密碼、商家ID,沒有AuthKey,
那么黑客截獲了URL,因為沒有包含AuthKey值(在商家系統和平臺才有),
那么就不能生成Sign值,所以就無法隨意訪問網店資訊,這樣就安全了。
uj5u.com熱心網友回復:
不知道為啥要弄個什么密碼。我將MD5演算法,在delphi7.0下編譯,將某字串加密,得到的32位的密文是A,將同樣的程式,放到delphi xe3下編譯,將同樣的字串加密,得到的是字串B。
同樣的md5演算法,因為編譯的語言不同,得到的結果也是不同的。
uj5u.com熱心網友回復:
你不知道你D7是ANSI字符,XE3是Unicode編碼嗎?這是基礎知識,請好好補習一下。你在sql server中的varchar和nvarchar編碼后的值也是不一樣的。
uj5u.com熱心網友回復:
MD5不存在密鑰一說,你客戶所謂的密鑰,肯定說法有問題,可能是一種組合加密演算法,最后生成md5而已。例如123加密以后是20xxxxxxxx……,如果加入一個你所謂的密鑰a,就成了123a,結果就是5dxxx.....沒有這個a,你就得不到最終結果,所以……如果我理解正確,這個也不能叫密鑰……密鑰的意思是回傳明文……很顯然,md5是不可能的……uj5u.com熱心網友回復:
模擬sha1、hmac-sha1的密鑰演算法。比如很多網站的后臺資料api的rest方式,就是用md5和hmac-sha1演算法的。
多看java代碼,很清楚的。
delphi低版本的關于網路的演算法,都要依靠第三方控制元件或代碼,
有些甚至要通過呼叫dll來處理。
這就是delphi的特點。
uj5u.com熱心網友回復:
你的加密方式可能被改造過了,不是標準的
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/130934.html
標籤:數據庫相關
