I use OpenSSL for this stuff, which can be compiled directly into your project.<div><br></div><div>{$ifdef windows} </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>// optionally link library into the project</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{$define static}<br><div>{$endif}</div><div><br></div><div>{$ifdef static}</div><div> {$define libssl := external}</div><div> {$define libeay := external}</div>
<div>{$else}</div><div> {$ifdef unix}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> {$define libssl := external 'libssl.so'}</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>{$define libeay := external 'libssl.so'}</div>
<div> {$else}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> {$define libssl := external 'libssl32.dll'}</div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>{$define libeay := external 'libeay32.dll'}</div>
<div> {$endif}</div><div>{$endif}</div><div><br></div><div>function SSL_library_init: Integer; cdecl; libssl;</div><div>procedure SSL_load_error_strings; cdecl; libssl;</div><div>function SSLv23_client_method: TSSLMethod; cdecl; libssl;</div>
<div>function SSL_CTX_new(method: TSSLMethod): TSSLCtx; cdecl; libssl;</div><div>procedure SSL_CTX_free(context: TSSLCtx); cdecl; libssl;</div><div>function SSL_new(context: TSSLCtx): TSSL; cdecl; libssl;</div><div>function SSL_shutdown(ssl: TSSL): LongInt; cdecl; libssl;</div>
<div>procedure SSL_free(ssl: TSSL); cdecl; libssl;</div><div>function SSL_set_fd(ssl: TSSL; socket: LongInt): LongBool; cdecl; libssl;</div><div>function SSL_connect(ssl: TSSL): LongBool; cdecl; libssl;</div><div>function SSL_write(ssl: TSSL; buffer: Pointer; size: LongWord): LongInt; cdecl; libssl;</div>
<div>function SSL_read(ssl: TSSL; buffer: Pointer; size: LongWord): LongInt; cdecl; libssl;</div><div>function SSL_get_error(ssl: TSSL; ret_code: Integer): Integer; cdecl; libssl;</div><div><br></div><div>{ Hashing routines }</div>
<div><br></div><div>function MD5_Init(out context: TMD5Ctx): LongBool; cdecl; libeay;</div><div>function MD5_Update(var context: TMD5Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;</div><div>function MD5_Final(out digest: TMD5Digest; var context: TMD5Ctx): LongBool; cdecl; libeay;</div>
<div>function SHA1_Init(out context: TSHA1Ctx): LongBool; cdecl; libeay;</div><div>function SHA1_Update(var context: TSHA1Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;</div><div>function SHA1_Final(out digest: TSHA1Digest; var context: TSHA1Ctx): LongBool; cdecl; libeay;</div>
<div>function SHA256_Init(out context: TSHA256Ctx): LongBool; cdecl; libeay;</div><div>function SHA256_Update(var context: TSHA256Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;</div><div>function SHA256_Final(out digest: TSHA256Digest; var context: TSHA256Ctx): LongBool; cdecl; libeay;</div>
<div>function SHA512_Init(out context: TSHA512Ctx): LongBool; cdecl; libeay;</div><div>function SHA512_Update(var context: TSHA512Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;</div><div>function SHA512_Final(out digest: TSHA512Digest; var context: TSHA512Ctx): LongBool; cdecl; libeay;</div>
<div>function EVP_md5: TEVPMethod; cdecl; libeay;</div><div>function EVP_sha1: TEVPMethod; cdecl; libeay;</div><div>function EVP_sha256: TEVPMethod; cdecl; libeay;</div><div>function EVP_sha512: TEVPMethod; cdecl; libeay;</div>
<div>procedure HMAC_CTX_init(out context: THMACCtx); cdecl; libeay;</div><div>procedure HMAC_CTX_cleanup(var context: THMACCtx); cdecl; libeay;</div><div>function HMAC_Init_ex(var context: THMACCtx; key: Pointer; size: Cardinal; method: TEVPMethod; engine: Pointer): LongBool; cdecl; libeay;</div>
<div>function HMAC_Update(var context: THMACCtx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;</div><div>function HMAC_Final(var context: THMACCtx; digest: Pointer; var digestSize: LongWord): LongBool; cdecl; libeay;</div>
</div><div><br></div><div><div>implementation</div><div><br></div><div>{$ifdef static}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{$linklib libssl.a}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{$linklib libcrypto.a}</div>
<div>{$endif}</div><div> </div></div>