Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string enc(string a)
- {
- char[] x = a.ToCharArray();
- string j = "";
- for (int i = 0; i < x.Length; i++)
- {
- j += Convert.ToChar(ExponentiationModulo(x[i], ee, n));
- }
- return j;
- }
- long ExponentiationModulo(long Number, long Degree, long Modulo)
- {
- long Result = 1; //Переменная-результат
- while (Degree > 0) //Цикл, вычисляющий результат
- {
- if (Degree % 2 == 0)
- {
- Degree /= 2;
- Number = (Number * Number) % Modulo;
- }
- else
- {
- Degree--;
- Result = (Result * Number) % Modulo;
- }
- }
- return Result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement