/*
 * $Id: encode.prg 11870 2009-07-21 17:41:17Z vszakats $
 */

/*
 * Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
 * www - http://www.harbour-project.org
 */

#include "simpleio.ch"

#include "hbssl.ch"

PROCEDURE Main()

   LOCAL ctx
   LOCAL result
   LOCAL encrypted
   LOCAL decrypted

   LOCAL cKey := "key"

   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
