S
S
SerS2015-12-01 16:57:40
Java
SerS, 2015-12-01 16:57:40

How to operate on bytes in java?

Hello.
I wrote the RSA encryption algorithm (just to learn) and everything works fine, but some kind of crutch comes out.
The key generation and encryption algorithm are great, but the problem is this:
To encrypt, I convert the object to an array of bytes, then I convert the byte to an int, then I need to raise the number to the power of n and take the remainder modulo m, then the result is back to bytes view .. some unrealistic scheme .. how to do the same in byte form? That is, take a byte, raise to a power and divide modulo?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Martyanov, 2015-12-01
@vilgeforce

Because RSA can produce numbers with more than 64 bits, so-called "long arithmetic" must be used to store them. If you supplement it with the modexp() function and functions for converting any array of bytes to a "long number" and vice versa, you can implement RSA in just three lines of code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question