Jump to content
  • Advertisement
Sign in to follow this  
fliar

Any one who's familiar with Raknet?Regarding RSAencrypt

This topic is 2860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i just want to encrypt something with RSA in raknet, but when i wrote a test toy, i found that it's not working, could anyone who can figure me out what the problem is?
here's the code on VS2005
the var 'temp' is still not readable after the decryption, i don't know why...
<Code>

#include "RSACrypt.h"
#include "BitStream.h"
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
// RSACrypt is a class that handles RSA encryption/decryption internally
RSACrypt rsacrypt;

uint32_t e;
uint32_t modulus[RAKNET_RSA_FACTOR_LIMBS];
// e and modulus form the public key

// p,q is the private key
uint32_t p[RAKNET_RSA_FACTOR_LIMBS/2],q[RAKNET_RSA_FACTOR_LIMBS/2];

uint32_t n[RAKNET_RSA_FACTOR_LIMBS], message[RAKNET_RSA_FACTOR_LIMBS], encryptedMessage[RAKNET_RSA_FACTOR_LIMBS];
uint32_t temp[RAKNET_RSA_FACTOR_LIMBS];

rsacrypt.generatePrivateKey(RAKNET_RSA_FACTOR_LIMBS);
e=rsacrypt.getPublicExponent();
rsacrypt.getPublicModulus(modulus);
rsacrypt.getPrivateP(p);
rsacrypt.getPrivateQ(q);


char* words="hello";
memcpy(message, words, 6);
rsacrypt.encrypt(encryptedMessage, message);

rsacrypt.decrypt(temp, encryptedMessage);

return 0;
}

</Code>

Share this post


Link to post
Share on other sites
Advertisement
sorry i knew it's not related to network much, but i think people here may know raknet better, and i couldn't find a more suitable forum...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!