/* This is used as an argument to bc. First pick two prime numbers greater than 50000. Substitute these in all p = and q = statements below. Then set g equal to the phi or quotient function of n. Use the command: bc generator | tee keylist This will allow the results to be recorded as you interact with bc generator. By following a sequence a = 1234 cr e(a) cr d(a) cr repeat, repeat, etc the file keylist is produced which will consist of a column of encryption/decryption pairs. Record n at the beginning, and the result is a raw unformated list of enc/dec pairs. */ define f(m,p,q) { z = 1 for(j = p ; j > 0 ; j = j / 2 ) { if( j % 2 == 1 ) { z = z * m % q } m = m * m % q } return(z) } define e(x) { auto p , q , n , f , g , h p = 53269 q = 40709 n = p * q f = (p - 1) * (q - 1) g = 16 * 2 * 22 * 192 * 10176 return(f(97,x,f)) } define d(x) { auto p , q , n , f , g , h p = 53269 q = 40709 n = p * q f = (p - 1) * (q - 1) g = 16 * 2 * 22 * 192 * 10176 h = g - x return(f(97,h,f)) } p = 53269 q = 40709 n = p * q f = (p - 1) * (q - 1) g = 16 * 2 * 22 * 192 * 10176 h = g - 12345 x = f(97,h,f) y = f(97,12345,f) u = e(12345) v = d(12345)