@rubarb

M * exp(e)

That’s really not doing what you expect. Me can be computed with pow(M, e).

Please log in or register to post a reply.

@rubarb

M * exp(e)

That’s really not doing what you expect. Me can be computed with pow(M, e).

I did try that first. I’ve re-tried with the following results:

…

C = -145

d = 22

m = -145

If your getting different results please show code?

The result of pow(11, 23) is gigantic, it’s even too large to store in a double without loosing precision. On top of that, the primes you’re using are way too small; the encryption can be broken really easily.

So what’s the intent of this? :huh:

I did wonder whether this was a problem. I tried using unsigned long’s to see if result was slightly different, it wasn’t.

I’m currently looking at http://www.efgh.com/software/rsa.htm, this defines it’s own data type from what I can tell, using an unsigned, or unsigned short, as they call it ‘mpuint’. To be honest i’m new to such large numbers, yet aware. In one book I have it mentions <complex> numbers, but not really looked at them yet.

For now i’m just messing around trying to write programs from reading ‘The Code Book’ by Simon Singh (this is why the primes are small).

The final use is for a simple encryption method for an in-game chat client. Also i’m aware of alternative existing methods for secure communication, but hey I like to try…

Cheers for any help!

It’s definitely worth it to try to implement RSA for your own experience. But if you want to use encryption for something serious like chatting in a game, it would be far easier to find an existing encryption library.

However, under the assumption that you do want to do RSA yourself, you will need a data type capable of storing very large numbers (bigger than 32 bits or even 64 bits). With a little bit of work, you can implement this yourself with a C++ class. You just need to break up the number into 32-bit chunks. It’s as if each chunk is a digit, and the number is being expressed in base 232. Addition, multiplication, and all the usual operations can be implemented on such numbers essentially by the same algorithms that you would use in grade school to work with multi-digit numbers in base 10.

Also, be aware that even if you get it working perfectly RSA is rather slow. Most systems that use RSA to do data encryption actually only use RSA at the beginning of a conversation, to agree upon a symmetric encryption key. The rest of the conversation is encrypted using a symmetric method (the same key both encodes and decodes the data), which is much faster.

- Upcoming Multiplatform Game Program...
- Our first game - looking for feedbacks
- Network Emulation Tool
- Trouble with accessing GLSL array
- Fiction
- Game Programming Patterns: Bytecode
- Interactive WebGL Water Demo
- Skeletal Animation Tutorial with GP...
- Unreal Engine 4
- Microsoft xbox one selling poorly

Hi, probably not the best place for this but maybe someone can help.

For one of my programs i’m trying to impliment my own version of the RSA algorithm, the encryption works fine, however the decrption does not, even though it uses basically the same algorithm. The code is as follows:

When decrypting I have put in actual values for the keys etc, and the result should be 88.

The actual formulas are:

ENCRYPT: C = Me (Mod N)

DECRYPT: M = Cd (Mod N)

*** Please note the ‘e’ and ‘d’ are supposed to be superscript, e.g. raised to the power of…