Files
harbour-core/contrib/hbssl/tests/encode.prg
Viktor Szakats 58faf91453 2016-01-14 19:17 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
* *
    % remove brandings and homepage [1] from copyright header. Pass 1 - using script.
      [1] nobody has access to it anymore AFAIK - and it's also just
          a redirect since long
    ! update url in copyright header
    ; this should make the diff between 3.4 and 3.2 easier to manage
2016-01-14 19:18:17 +01:00

43 lines
765 B
Plaintext

/*
* Copyright 2009 Viktor Szakats (vszakats.net/harbour)
*/
#require "hbssl"
PROCEDURE Main()
LOCAL ctx
LOCAL result
LOCAL encrypted
LOCAL decrypted
SSL_init()
OpenSSL_add_all_ciphers()
ctx := hb_EVP_ENCODE_ctx_create()
EVP_EncodeInit( ctx )
encrypted := ""
result := ""
EVP_EncodeUpdate( ctx, @result, "sample text" )
encrypted += result
EVP_EncodeFinal( ctx, @result )
encrypted += result
? "ENCRYTPTED", ">" + encrypted + "<"
ctx := hb_EVP_ENCODE_ctx_create()
EVP_DecodeInit( ctx )
decrypted := ""
result := ""
EVP_DecodeUpdate( ctx, @result, encrypted )
decrypted += result
EVP_DecodeFinal( ctx, @result )
decrypted += result
? "DECRYTPTED", ">" + decrypted + "<"
RETURN