<div dir="ltr">2013/3/26 Anthony Walter <span dir="ltr"><<a href="mailto:sysrpl@gmail.com" target="_blank">sysrpl@gmail.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I use OpenSSL for this stuff, which can be compiled directly into your project.<div><br></div><div>{$ifdef windows} </div><div><span style="white-space:pre-wrap"> </span>// optionally link library into the project</div>
<div><span style="white-space:pre-wrap"> </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 style="white-space:pre-wrap"> </span> {$define libssl := external 'libssl.so'}</div><div> <span style="white-space:pre-wrap"> </span>{$define libeay := external 'libssl.so'}</div>
<div> {$else}</div><div><span style="white-space:pre-wrap"> </span> {$define libssl := external 'libssl32.dll'}</div><div> <span style="white-space:pre-wrap"> </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 style="white-space:pre-wrap"> </span>{$linklib libssl.a}</div><div><span style="white-space:pre-wrap"> </span>{$linklib libcrypto.a}</div>
<div>{$endif}</div></div></blockquote></div><div><br></div><div style>Nice.</div><div style><br></div><div style>But there situations that the user does not have the OpenSSL lib.</div><div style><br></div><div style>The routines I sent does not depend on external libs.<br>
</div><div><br></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>