Rev 71 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 71 | Rev 75 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | function FileSystemCaseSensitive: boolean; |
20 | function FileSystemCaseSensitive: boolean; |
21 | function HighColorWindows: boolean; |
21 | function HighColorWindows: boolean; |
22 | function GetTempDir: string; |
22 | function GetTempDir: string; |
23 | function GetSpecialFolder(const aCSIDL: Integer): string; |
23 | function GetSpecialFolder(const aCSIDL: Integer): string; |
24 | function GetMyDocumentsFolder: string; |
24 | function GetMyDocumentsFolder: string; |
25 | function md5(value: string): string; |
25 | function MD5(const str: string): string; |
- | 26 | function MD5Stream(const s: TStream): string; |
|
26 | 27 | ||
27 | implementation |
28 | implementation |
28 | 29 | ||
29 | uses |
30 | uses |
30 | ShlObj, // Needed for the CSIDL constants |
31 | ShlObj, // Needed for the CSIDL constants |
Line 326... | Line 327... | ||
326 | function GetMyDocumentsFolder: string; |
327 | function GetMyDocumentsFolder: string; |
327 | begin |
328 | begin |
328 | Result := GetSpecialFolder(CSIDL_PERSONAL); |
329 | Result := GetSpecialFolder(CSIDL_PERSONAL); |
329 | end; |
330 | end; |
330 | 331 | ||
- | 332 | ||
- | 333 | {$IF gsIdVersion <> '10.1.5'} // Delphi 2007 built-in Indy10; gsIdVersion requires idGlobal.pas |
|
- | 334 | {$DEFINE NewIndy} |
|
- | 335 | {$IFEND} |
|
- | 336 | ||
331 | function md5(value: string): string; |
337 | function MD5Stream(const s: TStream): string; |
332 | var |
338 | var |
333 | hashMessageDigest5 : TIdHashMessageDigest5; |
339 | idmd5: TIdHashMessageDigest5; |
334 | begin |
340 | begin |
335 | hashMessageDigest5 := nil; |
341 | idmd5 := TIdHashMessageDigest5.Create; |
336 | try |
342 | try |
- | 343 | {$IFDEF NewIndy} |
|
337 | hashMessageDigest5 := TIdHashMessageDigest5.Create; |
344 | result := idmd5.HashStreamAsHex(s); |
- | 345 | {$ELSE} |
|
338 | Result := IdGlobal.IndyLowerCase(hashMessageDigest5.HashStringAsHex(value)); |
346 | result := idmd5.AsHex(idmd5.HashValue(s)); |
- | 347 | {$ENDIF} |
|
339 | finally |
348 | finally |
340 | hashMessageDigest5.Free; |
349 | idmd5.Free; |
- | 350 | end; |
|
341 | end; |
351 | end; |
- | 352 | ||
- | 353 | function MD5(const str: string): string; |
|
- | 354 | {$IFDEF NewIndy} |
|
- | 355 | var |
|
- | 356 | idmd5: TIdHashMessageDigest5; |
|
- | 357 | begin |
|
- | 358 | idmd5 := TIdHashMessageDigest5.Create; |
|
- | 359 | try |
|
- | 360 | result := idmd5.HashStringAsHex(str,IndyTextEncoding_OSDefault); |
|
- | 361 | finally |
|
- | 362 | idmd5.Free; |
|
342 | end; |
363 | end; |
- | 364 | {$ELSE} |
|
- | 365 | var |
|
- | 366 | ss: TStringStream; |
|
- | 367 | begin |
|
- | 368 | ss := TStringStream.Create(str); |
|
- | 369 | try |
|
- | 370 | result := MD5Stream(ss); |
|
- | 371 | finally |
|
- | 372 | ss.Free; |
|
- | 373 | end; |
|
- | 374 | {$ENDIF} |
|
- | 375 | end; |
|
- | 376 | ||
343 | 377 | ||
344 | end. |
378 | end. |