Files
harbour-core/harbour/contrib/hbssl/tests/encode.prg
Viktor Szakats 1b4008723b 2012-01-06 16:13 UTC+0100 Viktor Szakats (harbour syenar.net)
* ChangeLog
  * (whole tree)
    * changed e-mail address
2012-01-06 15:28:23 +00:00

50 lines
842 B
Plaintext

/*
* $Id$
*/
/*
* Copyright 2009 Viktor Szakats (harbour syenar.net)
* www - http://harbour-project.org
*/
#include "simpleio.ch"
#include "hbssl.ch"
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