swiftson

server crypt

Nov 23rd, 2013
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. rednet.open("top")
  2. t = {2, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 43}
  3. g = 200
  4. c = 1
  5. p, q, d, n, e, m, a, d1, d2, d3, d4 = 0
  6.  
  7. function generate()
  8.     q = t[math.random(1, 13)]
  9.     p = t[math.random(1, 13)]
  10.     while p == q do
  11.         p = t[math.random(1, 13)]
  12.     end
  13.     n = p*q
  14. end
  15.  
  16. function e()
  17.     e = t[math.random(2, 13)]
  18.     while n%e == 0 do
  19.         e = t[math.random(2, 13)]
  20.     end
  21. end
  22.  
  23. function check()
  24.     m = (4^e)%n
  25.     d = 3
  26.     for i = 1, g do
  27.         c = (m^d)%n
  28.         if c == 4 then
  29.             g = i
  30.         else
  31.             d = d + 2
  32.         end
  33.     end
  34. end
  35.  
  36. function send()
  37.     generate()
  38.     e()
  39.     check()
  40.     rednet.send(route, n)
  41.     rednet.send(route, e)
  42. end
  43.  
  44. function decrypt()
  45.     d1 = (e1^d)%n
  46.     d2 = (e2^d)%n
  47.     d3 = (e3^d)%n
  48.     d4 = (e4^d)%n
  49. end
  50.  
  51.  
  52.  
  53.  
  54. route, a, dis = rednet.receive()
  55.  
  56. if a == 5 then
  57.     send()
  58.     route, account, dis = rednet.receive()
  59.    
  60.     route, e1, dis = rednet.receive()
  61.     route, e2, dis = rednet.receive()
  62.     route, e3, dis = rednet.receive()
  63.     route, e4, dis = rednet.receive()
  64.     decrypt()
  65.  
  66.     print(d1 .. d2 .. d3 .. d4)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment