Nova DLL para assinatura (Registro EAD) para Harbour

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

Iwasa
Usuário Nível 1
Usuário Nível 1
Mensagens: 45
Registrado em: 16 Ago 2007 08:27
Localização: PRES. PRUDENTE SP
Contato:

Nova DLL para assinatura (Registro EAD) para Harbour

Mensagem por Iwasa »

DLL para download BEMAFI32.ZIP: http://www.bematech.com.br/suporte/down ... mafi32.zip
Link para a FONTE deste código: http://social.msdn.microsoft.com/Forums ... ff8a64535a

Código: Selecionar todos

/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
    /*
          * $Id: SIGNBEMA_C.C  ,v 1.0.0  2009/08/04 21:07:27 Reynaldoh Exp $
     */
 
/* Use this format for the entry headers:
      YYYY-MM-DD HH:MM UTC[-|+]hhmm Your Full Name <your_email@address>
      For example:
      2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
/*
        (C) 2009 - Luiz Augusto - São José dos Pinhais - PR laugusto@acbusca.com
        (C) 2009  - Reynaldo Henrique <rhfsystems@yahoo.com.br>
          * Ideia incial básica: foi de Luiz Augusto - PR  email: laugusto@acbusca.com
          * Idéia de continuação:  Reynaldo Henrique <rhfsystems@yahoo.com.br
  	                            	                          MSN: rhfsystem_reynaldo@hotmail.com>
 
		2009/08/04 21:07:27 UTC-0300 Reynaldo Henrique <rhfsystems@yahoo.com.br>
		* Implementações úteis para ser usadas junto com a DLL Sign_Bema.dll da Bematech.
		* Ideia incial básica: foi de Luiz Augusto - São José dos Pinhais - PR laugusto@acbusca.com
		* Idéia de continuação:  Reynaldo Henrique <rhfsystems@yahoo.com.br
		/ rhfsystem_reynaldo@hotmail.com>
*/
/*  Licença:
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2, or (at your option )
    * any later version.
  
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
 
  * You should have received a copy of the GNU General Public License
  * along with this software; see the file COPYING.   If not, write to
  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/ ).
 
  * As a special exception, the Harbour Project gives permission for
  * additional uses of the text contained in its release of Harbour.
 
  * The exception is that, if you link the Harbour libraries with other
  * files to produce an executable, this does not by itself cause the
  * resulting executable to be covered by the GNU General Public License.
  * Your use of that executable is in no way restricted on account of
  * linking the Harbour library code into it.
 
  * This exception does not however invalidate any other reasons why
  * the executable file might be covered by the GNU General Public License.
 
  * This exception applies only to the code released by the Harbour
  * Project under the name Harbour.  If you copy code from other
  * Harbour Project or Free Software Foundation releases into a copy of
  * Harbour, as the General Public License permits, the exception does
  * not apply to the code that you add in this way.   To avoid misleading
  * anyone as to the status of such modified files, you must delete
  * this exception notice from them.
 
  * If you write modifications of your own for Harbour, it is your choice
  * whether to permit this exception to apply to your modifications.
  * If you do not wish that, delete this exception notice.
 
 */
/*
*        Authors:
*        (C) 2009 - Luiz Augusto - São José dos Pinhais - PR laugusto@acbusca.com
*        (C) 2009  - Reynaldo Henrique <rhfsystems@yahoo.com.br>
*/
/*
        changelog
		2009-08-04 11:46 UTC-0300 Reynaldo Henrique <rhfsystems@yahoo.com.br>
          *  Alteração para ficar compativel com compiladores  BCC55,  XCC,  MSVC e PellesC.
	 	 *  Resolvido Todos os warnings de compilação.
          *  Passamos a usar HMODULE handle, em vez da forma nativa void* handle
*/
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
#include <windows.h>
#include "hbapi.h"
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
#ifdef __cplusplus
   extern "C" {
#endif
#define TAMANHO_STRING            256
#if defined(__BORLAND__)
      #define TAMANHO_STRING_DLL     TAMANHO_STRING
#else
      #define TAMANHO_STRING_DLL     TAMANHO_STRING+1
#endif
 
#if defined(__BORLANDC__)
   /* TO-DO in future version, if necessary */
#elif defined(_MSC_VER)
   /* TO-DO in future version, if necessary */
#elif defined(__MINGW32__) || defined(__CYGWIN__)
   /* TO-DO in future version, if necessary */
      #if defined(__CYGWIN__)
      /* TO-DO in future version, if necessary */
      #endif
#elif defined(__DMC__)
    /* TO-DO in future version, if necessary */
#elif defined(__DJGPP__)
    /* TO-DO in future version, if necessary */
#elif defined(__WATCOMC__)
    /* TO-DO in future version, if necessary */
#elif defined(HB_OS_DARWIN)
    /* TO-DO in future version, if necessary */
#endif
 
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
typedef int (__stdcall * _GENKKEY) ( char* cChavePublica, char* cChavePrivada );
typedef int (__stdcall * _SETLIBTYPE)( int iTipo );
typedef int (__stdcall * _GENERATEEAD)( char* cNomeArquivo, char*  cChavePublica,
                         char* cChavePrivada, char* cEAD, int iSign );
typedef int (__stdcall * _VALIDATEFILE)( char* cNomeArquivo,
        char* cChavePublica, char* cChavePrivada );
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
HB_FUNC( GENKKEY )
{
   HMODULE handle = LoadLibrary( "sign_bema.dll" );
   if ( handle )
   {
      char cChavePublica[TAMANHO_STRING_DLL] = {0};
      char cChavePrivada[TAMANHO_STRING_DLL] = {0};
      _GENKKEY pFunc = (_GENKKEY)GetProcAddress( handle, "genkkey" );
      hb_retni( pFunc( cChavePublica, cChavePrivada ) );
      hb_storc( cChavePublica, 1 );
      hb_storc( cChavePrivada, 2 );
      FreeLibrary( handle );
   }
}
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
HB_FUNC( SETLIBTYPE )
{
   HMODULE handle = LoadLibrary( "sign_bema.dll" );
   if ( handle )
   {
      int iTipo = hb_parni( 1 );
      _SETLIBTYPE pFunc = (_SETLIBTYPE)GetProcAddress( handle, "setLibType" );
      hb_retni( pFunc( iTipo ) );
      FreeLibrary( handle );
   }
}
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
HB_FUNC( GENERATEEAD )
{
   HMODULE handle = LoadLibrary( "sign_bema.dll" );
   if ( handle )
   {
      char cNomeArquivo [TAMANHO_STRING_DLL] = {0};
      char cChavePublica[TAMANHO_STRING_DLL] = {0};
      char cChavePrivada[TAMANHO_STRING_DLL] = {0};
      char cEAD[TAMANHO_STRING_DLL] = {0};
      int iSign;
   _GENERATEEAD pFunc = (_GENERATEEAD) GetProcAddress( handle, "generateEAD");
        #if defined(_MSC_VER) && !defined(__XCC__) && !defined(__POCC__)
	    strcpy_s(cNomeArquivo,hb_parc(1));
		strcpy_s(cChavePublica,hb_parc(2));
        strcpy_s(cChavePrivada,hb_parc(3));
        #else
	    strcpy(cNomeArquivo,hb_parc(1));
		strcpy(cChavePublica,hb_parc(2));
        strcpy(cChavePrivada,hb_parc(3));
        #endif
    iSign = hb_parni( 5 );
    hb_retni( pFunc( cNomeArquivo, cChavePublica, cChavePrivada, cEAD, iSign ) );
    hb_storc((char*)cEAD,4);
    FreeLibrary( handle );
   }
}
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
HB_FUNC( VALIDATEFILE )
{
    HMODULE handle = LoadLibrary( "sign_bema.dll" );
    if (handle)
    {
        char cNomeArquivo [TAMANHO_STRING_DLL] = {0};
        char cChavePublica[TAMANHO_STRING_DLL] = {0};
        char cChavePrivada[TAMANHO_STRING_DLL] = {0};
 
        _VALIDATEFILE pFunc = (_VALIDATEFILE)GetProcAddress(handle, "validateFile" );
				#if defined(_MSC_VER) && !defined(__XCC__) && !defined(__POCC__)
			strcpy_s(cNomeArquivo,hb_parc(1));
			strcpy_s(cChavePublica,hb_parc(2));
			strcpy_s(cChavePrivada,hb_parc(3));
				#else
			strcpy(cNomeArquivo,hb_parc(1));
			strcpy(cChavePublica,hb_parc(2));
			strcpy(cChavePrivada,hb_parc(3));
				#endif
        hb_retni( pFunc( cNomeArquivo, cChavePublica, cChavePrivada ) );
        FreeLibrary( handle );
    }
  }
#ifdef __cplusplus
        #if defined(_MSC_VER)
	    }  //  compatible with Microsoft C++
		#endif
#endif
/*  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */

Código: Selecionar todos

/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
/* $Id: teste_sign_bema.prg  ,v 1.0.0  2009/08/04 21:07:27 Reynaldoh Exp $ */
   /*
   Authors:
   * (C) 2009 - Luiz Augusto - laugusto@acbusca.com
   * (C) 2009  - Reynaldo Henrique <rhfsystems@yahoo.com.br>
 */
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */




PROCEDURE MAIN(xFile)
local cChavePublica := Space(256), cChavePrivada := Space(256)
local cEAD := space(256)
local nTipo := 0
local cFile := "teste.txt"
 
     if hb_argv(1) <> nil
        cFile := hb_argv(1)
     endif
 
	QOut( "Retorno de GENKKEY(...)    :" , ;
	GENKKEY( @cChavePublica, @cChavePrivada ) )
    QOut( "Chaves cChavePublica, cChavePrivada", ;
	cChavePublica, cChavePrivada )
    QOut( )
    QOut( "Retorno de SETLIBTYPE(...) :",SETLIBTYPE(nTipo) )
    QOut( )
    QOut( "Retorno de GENERATEEAD(...):",  ;
	GENERATEEAD( cFile, cChavePublica,cChavePrivada, @cEAD, 1 ) )
    QOut( )
    QOut( "Assinatura digital:", cEAD )
    MemoWrit( cFile, MemoRead(cFile)+cEAD + chr(13)+chr(10)  )
    QOut( "Retorno de VALIDATEFILE(...):", ;
	VALIDATEFILE(cFile, cChavePublica,cChavePrivada ) )
    __Wait( "Pressione qualquer tecla pra visualiar o conteudo do arquivo" )
    QOut( MemoRead(cFile) )
 
    __Wait( "Qualquer tecla, para sair..." )
 
RETURN
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
CLIPPER 5.3b/BLINKER 7.0/RDD CDX => Migrando para HARBOUR/RDD CDX

"Podemos construir um mundo melhor, compartilhando informações. Compartilhar conhecimento é edificar um mundo melhor para todos!".

http://iwasa.4shared.com/
lucimauro
Usuário Nível 3
Usuário Nível 3
Mensagens: 465
Registrado em: 21 Set 2004 21:02
Localização: Sobral-CE

Nova DLL para assinatura (Registro EAD) para Harbour

Mensagem por lucimauro »

Amigo falando em PAF-ECF voce ja fez sua homologacao,,queria saber se em harbour dar pra fazer tudos que eles exigem?

Desde ja obrigado.
Responder