I want to use RSA algorithm, for encrypt and decrypt messages. Now, as RSA can encrypt and decrypt Big-integer (or Integer) value, I need the message as Big-integer value. Now, message can contain strings like "ABC 123". What can I do ? Any help or suggestion ?
If your message is initially ascii, you can use something like:
BigInteger i = new BigInteger();
While(j < msg.length() ) {
i += ((byte)msg.charAt(j) << (j*7));
}
For working code consult the actual JavaDocs. But basically you just want to turn your bytes or chars into a number, so the idea is you just concatenate the bits together.
It can be done, by using
byte[] b = message.getBytes()
BigInteger = new BigInteger (b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With