Category: Javascript

Calculate Modular Exponentiation (PowerMod) in Javascript (a^p % n)

Calculate Modular Exponentiation (PowerMod) in Javascript (a^p % n)

Computing PowerMod is required for implementing public-key cryptography as it is used to encrypt and decrypt data. Calculating it by regular arithmetic (i.e. calculating pth power of a) doesn’t work with large numbers used for encryption. That’s where PowerMod helps, it calculates the result by keeping the numbers significantly small and within range of the integer data type.…

Read More Read More