You could do that which is essentially the equivalent of using ECB mode in block ciphers, but there are attacks on this. An attacker may reorder the different blocks of the ciphertext and you would decrypt it without problem, but the received plaintext would be broken without you knowing this....

cryptography,number-theory,elgamal

When you have: x * invX = 1 mod p the following equality is generally not true: (g ^ x) ^ invX = g mod p Above expression means multiplying g*g*....*g a certain number of times, x * invX, which is also k * p + 1 according to first...

BigInteger has a constructor taking a byte array as argument. Any String can be converted to a byte array, without loss, using (for example), UTF-8 encoding: byte[] bytes = string.getBytes(StandardCharsets.UTF_8); Combine both, and you have an easy way to transform a String into a BigDecimal. For the reverse operation, use...

I have no experience with cryptography, but, since no one else is answering, I'll give it a shot. Your question didn't quite make sense to me the way it was phrased, so I decided to implement a complete Elgamal in JavaScript so that I could understand your problem in context....