RSA Encryption
CSC-327 · Semester V · Cryptography
#include <stdio.h> long power_mod(long base, long exp, long mod) { long result = 1; base = base % mod; while (exp > 0) { if (exp % 2 == 1) result = (result * base) % mod; base = (base * base) % mod; exp = exp / 2; } return result; } int main() { long m = 65; long e = 17, n = 3233; long c = power_mod(m, e, n); printf("ciphertext = %ld\n", c); long d = 2753; long back = power_mod(c, d, n); printf("plaintext = %ld\n", back); return 0; }
Write some code, then press Run. Stdout and errors appear here.