Click here to Skip to main content
15,905,874 members

Comments by blackhattrick (Top 4 by date)

blackhattrick 13-Oct-12 18:44pm View    
blackhattrick - 46 mins ago
Hi GBSC thank you for your answer,

Yes I forgot to mention that I have that macro declared in each one of my header files(_LIST_, _NODE_), and that's why I'm confused about linker errors.

I didn't put my code because is rather long and some parts are in spanish, here is some part of my code that I consider relevant (I tried to put <pre> tags for a cleaner code but it does not work):

Lista.h //File List.h in my explanation of the problem
<pre lang="c++">
#ifndef _LISTA_
#define _LISTA_

#include <new>
#include "Nodo.h"
#include <iostream>
using std::cout;
#include <stdlib.h>
#include <time.h>

#define SUCCESS 0
#define ERROR -1
#define EMPTY_LIST -2

template
class Lista
{
public:
Lista();
~Lista();
void vdInsertarFrente(const TIPONODO &);
void vdInsertarFinal(const TIPONODO &);
int inBorrarFrente(void);
int inBorrarFinal(void);
bool blVacia();
void vdImprimir();
int vdShuffle(void);
int inGetLenght();
TIPONODO * inObtenerDatoNodo(int);

private:
int inLenght;
Nodo *ptrPrimero;
Nodo *ptrUltimo;
Nodo *ptrObtenerNuevoNodo(const TIPONODO &);
};

template
Lista::Lista()
{
ptrPrimero = 0;
ptrUltimo = 0;
}

//Here goes all my member functions...
#endif
</pre>

This is Main.cpp Here the Linker says that member functions from the List class are already defined
<pre lang="c++">
#include
using namespace std;

#include
#include
#include <process.h>

#include

#include "Lista.h" //Header of Lista.h
#include "Persona.h"
#include "Thread.h"
#include "GSALG.h" //A class that uses a List Object as a member

int main(void)
{
Lista<Persona> lstHombres;
Lista<Persona> lstMujeres;

//More code...
}
</pre>

And this is another header file GSALG.h (in my explanation is newheader.h) that declares a struct that uses a List object as a member. So I include Lista.h in this file

<pre lang="c++">
#ifndef _GSALG_
#define _GSALG_

#include "Lista.h";
#include "Persona.h";

typedef struct gsThreadArgs
{
Lista<Persona> lstHombres;
Lista<Persona> lstMujeres;
}gsThreadArgs;

#endif
</pre>

I hope this is clear enough.

Thanks in advance
blackhattrick 13-Oct-12 17:52pm View    
Deleted
Hi GBSC thank you for your answer,

Yes I forgot to mention that I have that macro declared in each one of my header files(_LIST_, _NODE_), and that's why I'm confused about linker errors.

I didn't put my code because is rather long and some parts are in spanish, here is some part of my code that I consider relevant:

Lista.h //File List.h in my explanation of the problem
<pre lang="c++">
#ifndef _LISTA_
#define _LISTA_

#include <new>
#include "Nodo.h"
#include <iostream>
using std::cout;
#include <stdlib.h>
#include <time.h>

#define SUCCESS 0
#define ERROR -1
#define EMPTY_LIST -2

template <class tiponodo="">
class Lista
{
public:
Lista();
~Lista();
void vdInsertarFrente(const TIPONODO &);
void vdInsertarFinal(const TIPONODO &);
int inBorrarFrente(void);
int inBorrarFinal(void);
bool blVacia();
void vdImprimir();
int vdShuffle(void);
int inGetLenght();
TIPONODO * inObtenerDatoNodo(int);

private:
int inLenght;
Nodo<tiponodo> *ptrPrimero;
Nodo<tiponodo> *ptrUltimo;
Nodo<tiponodo> *ptrObtenerNuevoNodo(const TIPONODO &);
};

template <class tiponodo="">
Lista<tiponodo>::Lista()
{
ptrPrimero = 0;
ptrUltimo = 0;
}

//Here goes all my member functions...
#endif
</pre>

This is Main.cpp Here the Linker says that member functions from the List class are already defined
<pre lang="c++">
#include <iostream>
using namespace std;

#include <fstream>
#include <windows.h>
#include <process.h>

#include <string>

#include "Lista.h" //Header of Lista.h
#include "Persona.h"
#include "Thread.h"
#include "GSALG.h" //A class that uses a List Object as a member

int main(void)
{
Lista<Persona> lstHombres;
Lista<Persona> lstMujeres;

//More code...
}
</pre>

And this is another header file GSALG.h (in my explanation is newheader.h) that declares a struct that uses a List object as a member. So I include Lista.h in this file

<pre lang="c++">
#ifndef _GSALG_
#define _GSALG_

#include "Lista.h";
#include "Persona.h";

typedef struct gsThreadArgs
{
Lista<Persona> lstHombres;
Lista<Persona> lstMujeres;
}gsThreadArgs;

#endif
</pre>

I hope this is clear enough.

Thanks in advance
blackhattrick 11-Apr-11 12:35pm View    
Thank you SAKryukov

Searching through codeproject, I found this article:
http://www.codeproject.com/KB/security/PrivateEncryption.aspx

As I feared, RSACryptoServiceProvider does not allow to encrypt data with the private key, and for porpuses of siging data, I would have to use some signin - verify methods of some other classes. This article implements a new RSA class for encrypting with the private key generated from the RSACryptoServiceProvider.

Im going to try this. I will post my results and if it works, Im going to close this tread as solutioned.

Thanks you for your help

Ivan
blackhattrick 10-Apr-11 16:20pm View    
Hi SAKryukov. Thank you for your feedback.

Im trying to create a RSA Key pair(public and private), and use the private key for encrypt data and decrypt it with the public key (I'm going to use this in a kind of file-signature schema). I think this is OK with the RSA standars

For what I have learned about generating RSA keys with C#, RSACryptoServiceProvider gives a pair of keys, a public one and a private one. So what I tried to do was create those 2 keys, getting the public key by creating a new RSACryptoServiceProvider and assigning it a public modulus and a public exponent from the first RSACryptoServiceProvider. Then I tried to encrypt some data with the first RSACryptoServiceProvider object, assuming that it will do it with the private key, and deencrypting the data with the second RSACryptoServiceProvider object.

If this is not the best way to create those 2 keys and do all the encryption/deencryption process that I need, could anyone suggest me something else? Thank you in advance.

Regards

Iván