Advertisement
xxmbabanexx

Coder v1.0

Apr 12th, 2013
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.03 KB | None
  1. """
  2. Please ignore the copyright notice - I orignially sold this to my friends at school.
  3. This application uses a basic Polyalphabetic algorithm to encrypt emails and such.
  4.  
  5. """
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. #Changes
  13. #
  14. #Larger output
  15. #Polyalphabetic Cipher
  16. #Added Quit
  17. #Added Settings
  18. #
  19. #Added encryption for more symbols!
  20. #
  21. #
  22. #
  23. #
  24. from Tkinter import *
  25. import tkMessageBox
  26. from ScrolledText import ScrolledText
  27. message = tkMessageBox
  28. SET = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
  29. ".",
  30. "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
  31. ]
  32. print len(SET)
  33. class Application(Frame):
  34. def __init__(self,master):
  35. Frame.__init__(self,master)
  36. self.grid()
  37. self.widget()
  38. self.pop_instruct()
  39. def pop_instruct(self):
  40. tkMessageBox.showinfo("Instructions",
  41. "To use the software follow these steps!\n 1. Choose a random number with you and your friends. Don't choose 0 because it is insecure!"\
  42. " \n2. Once you have done that then enter the number in the area that asks for your key! You can now use the software!!!"\
  43. "\n\nAlso, make sure to first put in the key otherwise the software won't work!!\n"
  44. ,)
  45. message.showinfo("\tCOPYRIGHT",
  46. "\tCopyright:\n"\
  47. "DO NOT DISTRIBUTE"\
  48. " (C) xDev INC.")
  49. def widget(self):
  50.  
  51.  
  52. #This is the welcoming text
  53. self.instruct = Label(self,
  54. text = "Hello and Welcome to the CODER software!\n", font = ("Times New Roman", 24, "bold"))
  55. #This places the instruct label
  56. self.instruct.grid(row = 1, column = 5, pady = 10,)
  57. self.help = Button(self,
  58. text ="Click me to learn how to use the software!",
  59. command = self.pop_instruct)
  60. self.help.grid(row = 2, column = 5)
  61.  
  62.  
  63. self.space1 = Label (self)
  64. self.space1.grid()
  65.  
  66.  
  67. #tells user to enter key
  68. self.key_bttn_one = Button(self,
  69. text = "Submit",
  70. command = self.key_def)
  71. #Says where the key label is
  72. self.key_bttn_one.grid(column = 5, row = 5)
  73.  
  74.  
  75. # This is the entry point that asks for the key
  76. self.key_enter_one= Entry(self)
  77. #this asks for the key's position
  78. self.key_enter_one.grid(row = 6, column = 5)
  79.  
  80. self.key_enter_two= Entry(self)
  81. #this asks for the key's position
  82. self.key_enter_two.grid(row = 7, column = 5)
  83.  
  84. self.key_enter_three= Entry(self)
  85. #this asks for the key's position
  86. self.key_enter_three.grid(row = 8, column = 5)
  87. #this is a submit button for the key
  88.  
  89. self.space1 = Label (self)
  90. self.space1.grid()
  91.  
  92. #Defines the label that tells the person to enter their plaintext
  93. self.plain_lbl = Label (self,
  94. text = "Enter your plaintext here!")
  95. # Defines where to put the plaintext label
  96. self.plain_lbl.grid(row = 9, column = 4, pady = 5)
  97.  
  98.  
  99. #Tells the person that they can enter their plaintext here
  100. self.plain_entry = ScrolledText(self, width = 100, height = 3)
  101. #defines where the entry point is
  102. self.plain_entry.grid(row = 9, column = 5, pady = 5)
  103. #This button submits the plaintext to the program
  104. self.plain_button = Button (self, text = "Click to Encrypt your message", command = self.encrypt_def)
  105.  
  106. #tells where the plaintext button should go
  107. self.plain_button.grid(row =9, column = 6, pady = 5)
  108.  
  109. self.space1 = Label (self)
  110. self.space1.grid()
  111. #This is the decryption label!
  112. self.cipher_lbl = Label (self,
  113. text = "Please enter the ciphertext here! : ")
  114. #Places the place where the decryption label is
  115. self.cipher_lbl.grid(row = 12, column = 4, pady = 5)
  116.  
  117. #This is where the user enters the ciphertext
  118. self.cipher_entry = ScrolledText(self, width = 100, height = 3)
  119. #this places the ciphertext
  120. self.cipher_entry.grid(row = 12, column = 5, pady=5)
  121.  
  122. #this is the button to submit the ciphertext for decryption!
  123.  
  124. self.cipher_button = Button (self, text = "Click to Decrypt the message!", command = self.decrypt_def)
  125.  
  126. self.cipher_button.grid(row = 12, column = 6, pady = 5)
  127.  
  128. #Displays the results of the coding
  129.  
  130.  
  131. self.results_plain_label = Label(self,
  132. text = "This is the deciphered message!!!")
  133. self.results_plain_label.grid(row = 13, column =5, pady = 5 )
  134. self.results_plain_text = ScrolledText (self, width = 100, height = 6, wrap = WORD, font = ("Times New Roman", ))
  135. self.results_plain_text.grid(row = 14, column = 5, pady = 5, sticky = W)
  136.  
  137.  
  138. self.space1 = Label (self)
  139. self.space1.grid()
  140. self.results_coded_label = Label(self,text = "This is the enciphered message!")
  141.  
  142. self.results_coded_label.grid(row = 16, column = 5, pady = 5)
  143. self.results_coded = ScrolledText (self, width = 100, height = 6, wrap = WORD, font = ("Times New Roman",))
  144. self.results_coded.grid(row = 17, column = 5, pady = 5, sticky = W)
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. def key_def(self):
  157. key_content_one = self.key_enter_one.get()
  158. key_content_two = self.key_enter_two.get()
  159. key_content_three = self.key_enter_three.get()
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. key_content_one = int(key_content_one)
  169. global key_one
  170. key_one = key_content_one % 26
  171. print key_one
  172.  
  173. key_content_two = int(key_content_two)
  174. global key_two
  175. key_two = key_content_two % 26
  176. print key_two
  177.  
  178. key_content_three = int(key_content_three)
  179. global key_three
  180. key_three = key_content_three % 26
  181. print key_three
  182. return key_one, key_two, key_three
  183.  
  184.  
  185.  
  186. def encrypt_def(self):
  187. WHICH = 0
  188. encrypt = self.plain_entry.get("0.0",END)
  189. global coded
  190. coded = ""
  191. for letter in encrypt:
  192. WHICH += 1
  193. WHICH = (WHICH % 3)
  194. for x in letter:
  195. if WHICH == 0:
  196. #normal code
  197. if letter == "a":
  198. cletter = SET[(key_one)% 53]
  199. coded += cletter
  200.  
  201. elif letter == "b":
  202. cletter = SET[(key_one+1)% 53]
  203. coded += cletter
  204.  
  205. elif letter == "c":
  206. cletter = SET[(key_one+2) % 53]
  207. coded += cletter
  208. elif letter == "d":
  209. cletter = SET[(key_one+3) % 53]
  210. coded += cletter
  211.  
  212. elif letter == "e":
  213. cletter = SET[(key_one+4) % 53]
  214. coded += cletter
  215.  
  216. elif letter == "f":
  217. cletter = SET[(key_one+5) % 53]
  218. coded += cletter
  219.  
  220. elif letter == "g":
  221. cletter = SET[(key_one+6) % 53]
  222. coded += cletter
  223.  
  224. elif letter == "h":
  225. cletter = SET[(key_one+7) % 53]
  226. coded += cletter
  227.  
  228. elif letter == "i":
  229. cletter = SET[(key_one+8) % 53]
  230. coded += cletter
  231.  
  232. elif letter == "j":
  233. cletter = SET[(key_one+9) % 53]
  234. coded += cletter
  235.  
  236. elif letter == "k":
  237. cletter = SET[(key_one+10) % 53]
  238. coded += cletter
  239.  
  240. elif letter == "l":
  241. cletter = SET[(key_one+11) % 53]
  242. coded += cletter
  243.  
  244. elif letter == "m":
  245. cletter = SET[(key_one+12) % 53]
  246. coded += cletter
  247.  
  248. elif letter == "n":
  249. cletter = SET[(key_one+13) % 53]
  250. coded += cletter
  251.  
  252. elif letter == "o":
  253. cletter = SET[(key_one+14) % 53]
  254. coded += cletter
  255.  
  256. elif letter == "p":
  257. cletter = SET[(key_one+15) % 53]
  258. coded += cletter
  259.  
  260. elif letter == "q":
  261. cletter = SET[(key_one+16) % 53]
  262. coded += cletter
  263.  
  264. elif letter == "r":
  265. cletter = SET[(key_one+17) % 53]
  266. coded += cletter
  267. elif letter == "s":
  268. cletter = SET[(key_one+18) % 53]
  269. coded += cletter
  270. elif letter == "t":
  271. cletter = SET[(key_one+19) % 53]
  272. coded += cletter
  273. elif letter == "u":
  274. cletter = SET[(key_one+20) % 53]
  275. coded += cletter
  276. elif letter == "v":
  277. cletter = SET[(key_one+21) % 53]
  278. coded += cletter
  279. elif letter == "w":
  280. cletter = SET[(key_one+22) % 53]
  281. coded += cletter
  282. elif letter == "x":
  283. cletter = SET[(key_one+23) % 53]
  284. coded += cletter
  285. elif letter == "y":
  286. cletter = SET[(key_one+24) % 53]
  287. coded += cletter
  288. elif letter == "z":
  289. cletter = SET[(key_one+25) % 53]
  290. coded += cletter
  291. elif letter == ".":
  292. cletter = SET[(key_one+26) % 53]
  293. coded += cletter
  294. elif letter == "A":
  295. cletter = SET [(key_one + 27) % 53]
  296. coded += cletter
  297. elif letter == "B":
  298. cletter = SET [(key_one + 28) % 53]
  299. coded += cletter
  300. elif letter == "C":
  301. cletter = SET [(key_one + 29) % 53]
  302. coded += cletter
  303. elif letter == "D":
  304. cletter = SET [(key_one + 30) % 53]
  305. coded += cletter
  306. elif letter == "E":
  307. cletter = SET [(key_one + 31) % 53]
  308. coded += cletter
  309. elif letter == "F":
  310. cletter = SET [(key_one + 32) % 53]
  311. coded += cletter
  312. elif letter == "G":
  313. cletter = SET [(key_one + 33) % 53]
  314. coded += cletter
  315. elif letter == "H":
  316. cletter = SET [(key_one + 34) % 53]
  317. coded += cletter
  318. elif letter == "I":
  319. cletter = SET [(key_one + 35) % 53]
  320. coded += cletter
  321. elif letter == "J":
  322. cletter = SET [(key_one + 36) % 53]
  323. coded += cletter
  324. elif letter == "K":
  325. cletter = SET [(key_one + 37) % 53]
  326. coded += cletter
  327. elif letter == "L":
  328. cletter = SET [(key_one + 38) % 53]
  329. coded += cletter
  330. elif letter == "M":
  331. cletter = SET [(key_one + 39) % 53]
  332. coded += cletter
  333. elif letter == "N":
  334. cletter = SET [(key_one + 40) % 53]
  335. coded += cletter
  336. elif letter == "O":
  337. cletter = SET [(key_one + 41) % 53]
  338. coded += cletter
  339. elif letter == "P":
  340. cletter = SET [(key_one + 42) % 53]
  341. coded += cletter
  342. elif letter == "Q":
  343. cletter = SET [(key_one + 43) % 53]
  344. coded += cletter
  345. elif letter == "R":
  346. cletter = SET [(key_one + 44) % 53]
  347. coded += cletter
  348. elif letter == "S":
  349. cletter = SET [(key_one + 45) % 53]
  350. coded += cletter
  351. elif letter == "T":
  352. cletter = SET [(key_one + 46) % 53]
  353. coded += cletter
  354. elif letter == "U":
  355. cletter = SET [(key_one + 47) % 53]
  356. coded += cletter
  357. elif letter == "V":
  358. cletter = SET [(key_one + 48) % 53]
  359. coded += cletter
  360. elif letter == "W":
  361. cletter = SET [(key_one + 49) % 53]
  362. coded += cletter
  363. elif letter == "X":
  364. cletter = SET [(key_one + 50) % 53]
  365. coded += cletter
  366. elif letter == "Y":
  367. cletter = SET [(key_one + 51) % 53]
  368. coded += cletter
  369. elif letter == "Z":
  370. cletter = SET [(key_one + 52) % 53]
  371. coded += cletter
  372. else:
  373. coded += letter
  374. WHICH -= 1
  375. for x in letter:
  376. if WHICH == 1:
  377. if letter == "a":
  378. cletter = SET[(key_two)% 53]
  379. coded += cletter
  380.  
  381. elif letter == "b":
  382. cletter = SET[(key_two+1)% 53]
  383. coded += cletter
  384.  
  385. elif letter == "c":
  386. cletter = SET[(key_two+2) % 53]
  387. coded += cletter
  388. elif letter == "d":
  389. cletter = SET[(key_two+3) % 53]
  390. coded += cletter
  391.  
  392. elif letter == "e":
  393. cletter = SET[(key_two+4) % 53]
  394. coded += cletter
  395.  
  396. elif letter == "f":
  397. cletter = SET[(key_two+5) % 53]
  398. coded += cletter
  399.  
  400. elif letter == "g":
  401. cletter = SET[(key_two+6) % 53]
  402. coded += cletter
  403.  
  404. elif letter == "h":
  405. cletter = SET[(key_two+7) % 53]
  406. coded += cletter
  407.  
  408. elif letter == "i":
  409. cletter = SET[(key_two+8) % 53]
  410. coded += cletter
  411.  
  412. elif letter == "j":
  413. cletter = SET[(key_two+9) % 53]
  414. coded += cletter
  415.  
  416. elif letter == "k":
  417. cletter = SET[(key_two+10) % 53]
  418. coded += cletter
  419.  
  420. elif letter == "l":
  421. cletter = SET[(key_two+11) % 53]
  422. coded += cletter
  423.  
  424. elif letter == "m":
  425. cletter = SET[(key_two+12) % 53]
  426. coded += cletter
  427.  
  428. elif letter == "n":
  429. cletter = SET[(key_two+13) % 53]
  430. coded += cletter
  431.  
  432. elif letter == "o":
  433. cletter = SET[(key_two+14) % 53]
  434. coded += cletter
  435.  
  436. elif letter == "p":
  437. cletter = SET[(key_two+15) % 53]
  438. coded += cletter
  439.  
  440. elif letter == "q":
  441. cletter = SET[(key_two+16) % 53]
  442. coded += cletter
  443.  
  444. elif letter == "r":
  445. cletter = SET[(key_two+17) % 53]
  446. coded += cletter
  447. elif letter == "s":
  448. cletter = SET[(key_two+18) % 53]
  449. coded += cletter
  450. elif letter == "t":
  451. cletter = SET[(key_two+19) % 53]
  452. coded += cletter
  453. elif letter == "u":
  454. cletter = SET[(key_two+20) % 53]
  455. coded += cletter
  456. elif letter == "v":
  457. cletter = SET[(key_two+21) % 53]
  458. coded += cletter
  459. elif letter == "w":
  460. cletter = SET[(key_two+22) % 53]
  461. coded += cletter
  462. elif letter == "x":
  463. cletter = SET[(key_two+23) % 53]
  464. coded += cletter
  465. elif letter == "y":
  466. cletter = SET[(key_two+24) % 53]
  467. coded += cletter
  468. elif letter == "z":
  469. cletter = SET[(key_two+25) % 53]
  470. coded += cletter
  471. elif letter == ".":
  472. cletter = SET[(key_two+26) % 53]
  473. coded += cletter
  474. elif letter == "A":
  475. cletter = SET [(key_two + 27) % 53]
  476. coded += cletter
  477. elif letter == "B":
  478. cletter = SET [(key_two + 28) % 53]
  479. coded += cletter
  480. elif letter == "C":
  481. cletter = SET [(key_two + 29) % 53]
  482. coded += cletter
  483. elif letter == "D":
  484. cletter = SET [(key_two + 30) % 53]
  485. coded += cletter
  486. elif letter == "E":
  487. cletter = SET [(key_two + 31) % 53]
  488. coded += cletter
  489. elif letter == "F":
  490. cletter = SET [(key_two + 32) % 53]
  491. coded += cletter
  492. elif letter == "G":
  493. cletter = SET [(key_two + 33) % 53]
  494. coded += cletter
  495. elif letter == "H":
  496. cletter = SET [(key_two + 34) % 53]
  497. coded += cletter
  498. elif letter == "I":
  499. cletter = SET [(key_two + 35) % 53]
  500. coded += cletter
  501. elif letter == "J":
  502. cletter = SET [(key_two + 36) % 53]
  503. coded += cletter
  504. elif letter == "K":
  505. cletter = SET [(key_two + 37) % 53]
  506. coded += cletter
  507. elif letter == "L":
  508. cletter = SET [(key_two + 38) % 53]
  509. coded += cletter
  510. elif letter == "M":
  511. cletter = SET [(key_two + 39) % 53]
  512. coded += cletter
  513. elif letter == "N":
  514. cletter = SET [(key_two + 40) % 53]
  515. coded += cletter
  516. elif letter == "O":
  517. cletter = SET [(key_two + 41) % 53]
  518. coded += cletter
  519. elif letter == "P":
  520. cletter = SET [(key_two + 42) % 53]
  521. coded += cletter
  522. elif letter == "Q":
  523. cletter = SET [(key_two + 43) % 53]
  524. coded += cletter
  525. elif letter == "R":
  526. cletter = SET [(key_two + 44) % 53]
  527. coded += cletter
  528. elif letter == "S":
  529. cletter = SET [(key_two + 45) % 53]
  530. coded += cletter
  531. elif letter == "T":
  532. cletter = SET [(key_two + 46) % 53]
  533. coded += cletter
  534. elif letter == "U":
  535. cletter = SET [(key_two + 47) % 53]
  536. coded += cletter
  537. elif letter == "V":
  538. cletter = SET [(key_two + 48) % 53]
  539. coded += cletter
  540. elif letter == "W":
  541. cletter = SET [(key_two + 49) % 53]
  542. coded += cletter
  543. elif letter == "X":
  544. cletter = SET [(key_two + 50) % 53]
  545. coded += cletter
  546. elif letter == "Y":
  547. cletter = SET [(key_two + 51) % 53]
  548. coded += cletter
  549. elif letter == "Z":
  550. cletter = SET [(key_two + 52) % 53]
  551. coded += cletter
  552. else:
  553. coded += letter
  554. WHICH -= 1
  555. for x in letter:
  556. if WHICH == 2:
  557. if letter == "a":
  558. cletter = SET[(key_three)% 53]
  559. coded += cletter
  560.  
  561. elif letter == "b":
  562. cletter = SET[(key_three+1)% 53]
  563. coded += cletter
  564.  
  565. elif letter == "c":
  566. cletter = SET[(key_three+2) % 53]
  567. coded += cletter
  568. elif letter == "d":
  569. cletter = SET[(key_three+3) % 53]
  570. coded += cletter
  571.  
  572. elif letter == "e":
  573. cletter = SET[(key_three+4) % 53]
  574. coded += cletter
  575.  
  576. elif letter == "f":
  577. cletter = SET[(key_three+5) % 53]
  578. coded += cletter
  579.  
  580. elif letter == "g":
  581. cletter = SET[(key_three+6) % 53]
  582. coded += cletter
  583.  
  584. elif letter == "h":
  585. cletter = SET[(key_three+7) % 53]
  586. coded += cletter
  587.  
  588. elif letter == "i":
  589. cletter = SET[(key_three+8) % 53]
  590. coded += cletter
  591.  
  592. elif letter == "j":
  593. cletter = SET[(key_three+9) % 53]
  594. coded += cletter
  595.  
  596. elif letter == "k":
  597. cletter = SET[(key_three+10) % 53]
  598. coded += cletter
  599.  
  600. elif letter == "l":
  601. cletter = SET[(key_three+11) % 53]
  602. coded += cletter
  603.  
  604. elif letter == "m":
  605. cletter = SET[(key_three+12) % 53]
  606. coded += cletter
  607.  
  608. elif letter == "n":
  609. cletter = SET[(key_three+13) % 53]
  610. coded += cletter
  611.  
  612. elif letter == "o":
  613. cletter = SET[(key_three+14) % 53]
  614. coded += cletter
  615.  
  616. elif letter == "p":
  617. cletter = SET[(key_three+15) % 53]
  618. coded += cletter
  619.  
  620. elif letter == "q":
  621. cletter = SET[(key_three+16) % 53]
  622. coded += cletter
  623.  
  624. elif letter == "r":
  625. cletter = SET[(key_three+17) % 53]
  626. coded += cletter
  627. elif letter == "s":
  628. cletter = SET[(key_three+18) % 53]
  629. coded += cletter
  630. elif letter == "t":
  631. cletter = SET[(key_three+19) % 53]
  632. coded += cletter
  633. elif letter == "u":
  634. cletter = SET[(key_three+20) % 53]
  635. coded += cletter
  636. elif letter == "v":
  637. cletter = SET[(key_three+21) % 53]
  638. coded += cletter
  639. elif letter == "w":
  640. cletter = SET[(key_three+22) % 53]
  641. coded += cletter
  642. elif letter == "x":
  643. cletter = SET[(key_three+23) % 53]
  644. coded += cletter
  645. elif letter == "y":
  646. cletter = SET[(key_three+24) % 53]
  647. coded += cletter
  648. elif letter == "z":
  649. cletter = SET[(key_three+25) % 53]
  650. coded += cletter
  651. elif letter == ".":
  652. cletter = SET[(key_three+26) % 53]
  653. coded += cletter
  654. elif letter == "A":
  655. cletter = SET [(key_three + 27) % 53]
  656. coded += cletter
  657. elif letter == "B":
  658. cletter = SET [(key_three + 28) % 53]
  659. coded += cletter
  660. elif letter == "C":
  661. cletter = SET [(key_three + 29) % 53]
  662. coded += cletter
  663. elif letter == "D":
  664. cletter = SET [(key_three + 30) % 53]
  665. coded += cletter
  666. elif letter == "E":
  667. cletter = SET [(key_three + 31) % 53]
  668. coded += cletter
  669. elif letter == "F":
  670. cletter = SET [(key_three + 32) % 53]
  671. coded += cletter
  672. elif letter == "G":
  673. cletter = SET [(key_three + 33) % 53]
  674. coded += cletter
  675. elif letter == "H":
  676. cletter = SET [(key_three + 34) % 53]
  677. coded += cletter
  678. elif letter == "I":
  679. cletter = SET [(key_three + 35) % 53]
  680. coded += cletter
  681. elif letter == "J":
  682. cletter = SET [(key_three + 36) % 53]
  683. coded += cletter
  684. elif letter == "K":
  685. cletter = SET [(key_three + 37) % 53]
  686. coded += cletter
  687. elif letter == "L":
  688. cletter = SET [(key_three + 38) % 53]
  689. coded += cletter
  690. elif letter == "M":
  691. cletter = SET [(key_three + 39) % 53]
  692. coded += cletter
  693. elif letter == "N":
  694. cletter = SET [(key_three + 40) % 53]
  695. coded += cletter
  696. elif letter == "O":
  697. cletter = SET [(key_three + 41) % 53]
  698. coded += cletter
  699. elif letter == "P":
  700. cletter = SET [(key_three + 42) % 53]
  701. coded += cletter
  702. elif letter == "Q":
  703. cletter = SET [(key_three + 43) % 53]
  704. coded += cletter
  705. elif letter == "R":
  706. cletter = SET [(key_three + 44) % 53]
  707. coded += cletter
  708. elif letter == "S":
  709. cletter = SET [(key_three + 45) % 53]
  710. coded += cletter
  711. elif letter == "T":
  712. cletter = SET [(key_three + 46) % 53]
  713. coded += cletter
  714. elif letter == "U":
  715. cletter = SET [(key_three + 47) % 53]
  716. coded += cletter
  717. elif letter == "V":
  718. cletter = SET [(key_three + 48) % 53]
  719. coded += cletter
  720. elif letter == "W":
  721. cletter = SET [(key_three + 49) % 53]
  722. coded += cletter
  723. elif letter == "X":
  724. cletter = SET [(key_three + 50) % 53]
  725. coded += cletter
  726. elif letter == "Y":
  727. cletter = SET [(key_three + 51) % 53]
  728. coded += cletter
  729. elif letter == "Z":
  730. cletter = SET [(key_three + 52) % 53]
  731. coded += cletter
  732. else:
  733. coded += letter
  734. WHICH -= 1
  735. print coded
  736.  
  737. self.results_coded.delete(0.0, END)
  738. self.results_coded.insert(0.0, coded)
  739.  
  740. def decrypt_def(self):
  741. WHICH = 0
  742. cipher = self.cipher_entry.get("0.0", END)
  743. normal = ""
  744. for letter in cipher:
  745. WHICH += 1
  746. WHICH = (WHICH % 3)
  747. for x in letter:
  748. if WHICH == 0:
  749. #normal code
  750. if letter == "a":
  751. cletter = SET[(-key_one)% 53]
  752. normal += cletter
  753.  
  754. elif letter == "b":
  755. cletter = SET[(-key_one+1)% 53]
  756. normal += cletter
  757.  
  758. elif letter == "c":
  759. cletter = SET[(-key_one+2) % 53]
  760. normal += cletter
  761. elif letter == "d":
  762. cletter = SET[(-key_one+3) % 53]
  763. normal += cletter
  764.  
  765. elif letter == "e":
  766. cletter = SET[(-key_one+4) % 53]
  767. normal += cletter
  768.  
  769. elif letter == "f":
  770. cletter = SET[(-key_one+5) % 53]
  771. normal += cletter
  772.  
  773. elif letter == "g":
  774. cletter = SET[(-key_one+6) % 53]
  775. normal += cletter
  776.  
  777. elif letter == "h":
  778. cletter = SET[(-key_one+7) % 53]
  779. normal += cletter
  780.  
  781. elif letter == "i":
  782. cletter = SET[(-key_one+8) % 53]
  783. normal += cletter
  784.  
  785. elif letter == "j":
  786. cletter = SET[(-key_one+9) % 53]
  787. normal += cletter
  788.  
  789. elif letter == "k":
  790. cletter = SET[(-key_one+10) % 53]
  791. normal += cletter
  792.  
  793. elif letter == "l":
  794. cletter = SET[(-key_one+11) % 53]
  795. normal += cletter
  796.  
  797. elif letter == "m":
  798. cletter = SET[(-key_one+12) % 53]
  799. normal += cletter
  800.  
  801. elif letter == "n":
  802. cletter = SET[(-key_one+13) % 53]
  803. normal += cletter
  804.  
  805. elif letter == "o":
  806. cletter = SET[(-key_one+14) % 53]
  807. normal += cletter
  808.  
  809. elif letter == "p":
  810. cletter = SET[(-key_one+15) % 53]
  811. normal += cletter
  812.  
  813. elif letter == "q":
  814. cletter = SET[(-key_one+16) % 53]
  815. normal += cletter
  816.  
  817. elif letter == "r":
  818. cletter = SET[(-key_one+17) % 53]
  819. normal += cletter
  820. elif letter == "s":
  821. cletter = SET[(-key_one+18) % 53]
  822. normal += cletter
  823. elif letter == "t":
  824. cletter = SET[(-key_one+19) % 53]
  825. normal += cletter
  826. elif letter == "u":
  827. cletter = SET[(-key_one+20) % 53]
  828. normal += cletter
  829. elif letter == "v":
  830. cletter = SET[(-key_one+21) % 53]
  831. normal += cletter
  832. elif letter == "w":
  833. cletter = SET[(-key_one+22) % 53]
  834. normal += cletter
  835. elif letter == "x":
  836. cletter = SET[(-key_one+23) % 53]
  837. normal += cletter
  838. elif letter == "y":
  839. cletter = SET[(-key_one+24) % 53]
  840. normal += cletter
  841. elif letter == "z":
  842. cletter = SET[(-key_one+25) % 53]
  843. normal += cletter
  844. elif letter == ".":
  845. cletter = SET[(-key_one+26) % 53]
  846. normal += cletter
  847. elif letter == "A":
  848. cletter = SET [(-key_one + 27) % 53]
  849. normal += cletter
  850. elif letter == "B":
  851. cletter = SET [(-key_one + 28) % 53]
  852. normal += cletter
  853. elif letter == "C":
  854. cletter = SET [(-key_one + 29) % 53]
  855. normal += cletter
  856. elif letter == "D":
  857. cletter = SET [(-key_one + 30) % 53]
  858. normal += cletter
  859. elif letter == "E":
  860. cletter = SET [(-key_one + 31) % 53]
  861. normal += cletter
  862. elif letter == "F":
  863. cletter = SET [(-key_one + 32) % 53]
  864. normal += cletter
  865. elif letter == "G":
  866. cletter = SET [(-key_one + 33) % 53]
  867. normal += cletter
  868. elif letter == "H":
  869. cletter = SET [(-key_one + 34) % 53]
  870. normal += cletter
  871. elif letter == "I":
  872. cletter = SET [(-key_one + 35) % 53]
  873. normal += cletter
  874. elif letter == "J":
  875. cletter = SET [(-key_one + 36) % 53]
  876. normal += cletter
  877. elif letter == "K":
  878. cletter = SET [(-key_one + 37) % 53]
  879. normal += cletter
  880. elif letter == "L":
  881. cletter = SET [(-key_one + 38) % 53]
  882. normal += cletter
  883. elif letter == "M":
  884. cletter = SET [(-key_one + 39) % 53]
  885. normal += cletter
  886. elif letter == "N":
  887. cletter = SET [(-key_one + 40) % 53]
  888. normal += cletter
  889. elif letter == "O":
  890. cletter = SET [(-key_one + 41) % 53]
  891. normal += cletter
  892. elif letter == "P":
  893. cletter = SET [(-key_one + 42) % 53]
  894. normal += cletter
  895. elif letter == "Q":
  896. cletter = SET [(-key_one + 43) % 53]
  897. normal += cletter
  898. elif letter == "R":
  899. cletter = SET [(-key_one + 44) % 53]
  900. normal += cletter
  901. elif letter == "S":
  902. cletter = SET [(-key_one + 45) % 53]
  903. normal += cletter
  904. elif letter == "T":
  905. cletter = SET [(-key_one + 46) % 53]
  906. normal += cletter
  907. elif letter == "U":
  908. cletter = SET [(-key_one + 47) % 53]
  909. normal += cletter
  910. elif letter == "V":
  911. cletter = SET [(-key_one + 48) % 53]
  912. normal += cletter
  913. elif letter == "W":
  914. cletter = SET [(-key_one + 49) % 53]
  915. normal += cletter
  916. elif letter == "X":
  917. cletter = SET [(-key_one + 50) % 53]
  918. normal += cletter
  919. elif letter == "Y":
  920. cletter = SET [(-key_one + 51) % 53]
  921. normal += cletter
  922. elif letter == "Z":
  923. cletter = SET [(-key_one + 52) % 53]
  924. normal += cletter
  925. else:
  926. normal += letter
  927. WHICH -= 1
  928. for x in letter:
  929. if WHICH == 1:
  930. if letter == "a":
  931. cletter = SET[(-key_two)% 53]
  932. normal += cletter
  933.  
  934. elif letter == "b":
  935. cletter = SET[(-key_two+1)% 53]
  936. normal += cletter
  937.  
  938. elif letter == "c":
  939. cletter = SET[(-key_two+2) % 53]
  940. normal += cletter
  941. elif letter == "d":
  942. cletter = SET[(-key_two+3) % 53]
  943. normal += cletter
  944.  
  945. elif letter == "e":
  946. cletter = SET[(-key_two+4) % 53]
  947. normal += cletter
  948.  
  949. elif letter == "f":
  950. cletter = SET[(-key_two+5) % 53]
  951. normal += cletter
  952.  
  953. elif letter == "g":
  954. cletter = SET[(-key_two+6) % 53]
  955. normal += cletter
  956.  
  957. elif letter == "h":
  958. cletter = SET[(-key_two+7) % 53]
  959. normal += cletter
  960.  
  961. elif letter == "i":
  962. cletter = SET[(-key_two+8) % 53]
  963. normal += cletter
  964.  
  965. elif letter == "j":
  966. cletter = SET[(-key_two+9) % 53]
  967. normal += cletter
  968.  
  969. elif letter == "k":
  970. cletter = SET[(-key_two+10) % 53]
  971. normal += cletter
  972.  
  973. elif letter == "l":
  974. cletter = SET[(-key_two+11) % 53]
  975. normal += cletter
  976.  
  977. elif letter == "m":
  978. cletter = SET[(-key_two+12) % 53]
  979. normal += cletter
  980.  
  981. elif letter == "n":
  982. cletter = SET[(-key_two+13) % 53]
  983. normal += cletter
  984.  
  985. elif letter == "o":
  986. cletter = SET[(-key_two+14) % 53]
  987. normal += cletter
  988.  
  989. elif letter == "p":
  990. cletter = SET[(-key_two+15) % 53]
  991. normal += cletter
  992.  
  993. elif letter == "q":
  994. cletter = SET[(-key_two+16) % 53]
  995. normal += cletter
  996.  
  997. elif letter == "r":
  998. cletter = SET[(-key_two+17) % 53]
  999. normal += cletter
  1000. elif letter == "s":
  1001. cletter = SET[(-key_two+18) % 53]
  1002. normal += cletter
  1003. elif letter == "t":
  1004. cletter = SET[(-key_two+19) % 53]
  1005. normal += cletter
  1006. elif letter == "u":
  1007. cletter = SET[(-key_two+20) % 53]
  1008. normal += cletter
  1009. elif letter == "v":
  1010. cletter = SET[(-key_two+21) % 53]
  1011. normal += cletter
  1012. elif letter == "w":
  1013. cletter = SET[(-key_two+22) % 53]
  1014. normal += cletter
  1015. elif letter == "x":
  1016. cletter = SET[(-key_two+23) % 53]
  1017. normal += cletter
  1018. elif letter == "y":
  1019. cletter = SET[(-key_two+24) % 53]
  1020. normal += cletter
  1021. elif letter == "z":
  1022. cletter = SET[(-key_two+25) % 53]
  1023. normal += cletter
  1024. elif letter == ".":
  1025. cletter = SET[(-key_two+26) % 53]
  1026. normal += cletter
  1027. elif letter == "A":
  1028. cletter = SET [(-key_two + 27) % 53]
  1029. normal += cletter
  1030. elif letter == "B":
  1031. cletter = SET [(-key_two + 28) % 53]
  1032. normal += cletter
  1033. elif letter == "C":
  1034. cletter = SET [(-key_two + 29) % 53]
  1035. normal += cletter
  1036. elif letter == "D":
  1037. cletter = SET [(-key_two + 30) % 53]
  1038. normal += cletter
  1039. elif letter == "E":
  1040. cletter = SET [(-key_two + 31) % 53]
  1041. normal += cletter
  1042. elif letter == "F":
  1043. cletter = SET [(-key_two + 32) % 53]
  1044. normal += cletter
  1045. elif letter == "G":
  1046. cletter = SET [(-key_two + 33) % 53]
  1047. normal += cletter
  1048. elif letter == "H":
  1049. cletter = SET [(-key_two + 34) % 53]
  1050. normal += cletter
  1051. elif letter == "I":
  1052. cletter = SET [(-key_two + 35) % 53]
  1053. normal += cletter
  1054. elif letter == "J":
  1055. cletter = SET [(-key_two + 36) % 53]
  1056. normal += cletter
  1057. elif letter == "K":
  1058. cletter = SET [(-key_two + 37) % 53]
  1059. normal += cletter
  1060. elif letter == "L":
  1061. cletter = SET [(-key_two + 38) % 53]
  1062. normal += cletter
  1063. elif letter == "M":
  1064. cletter = SET [(-key_two + 39) % 53]
  1065. normal += cletter
  1066. elif letter == "N":
  1067. cletter = SET [(-key_two + 40) % 53]
  1068. normal += cletter
  1069. elif letter == "O":
  1070. cletter = SET [(-key_two + 41) % 53]
  1071. normal += cletter
  1072. elif letter == "P":
  1073. cletter = SET [(-key_two + 42) % 53]
  1074. normal += cletter
  1075. elif letter == "Q":
  1076. cletter = SET [(-key_two + 43) % 53]
  1077. normal += cletter
  1078. elif letter == "R":
  1079. cletter = SET [(-key_two + 44) % 53]
  1080. normal += cletter
  1081. elif letter == "S":
  1082. cletter = SET [(-key_two + 45) % 53]
  1083. normal += cletter
  1084. elif letter == "T":
  1085. cletter = SET [(-key_two + 46) % 53]
  1086. normal += cletter
  1087. elif letter == "U":
  1088. cletter = SET [(-key_two + 47) % 53]
  1089. normal += cletter
  1090. elif letter == "V":
  1091. cletter = SET [(-key_two + 48) % 53]
  1092. normal += cletter
  1093. elif letter == "W":
  1094. cletter = SET [(-key_two + 49) % 53]
  1095. normal += cletter
  1096. elif letter == "X":
  1097. cletter = SET [(-key_two + 50) % 53]
  1098. normal += cletter
  1099. elif letter == "Y":
  1100. cletter = SET [(-key_two + 51) % 53]
  1101. normal += cletter
  1102. elif letter == "Z":
  1103. cletter = SET [(-key_two + 52) % 53]
  1104. normal += cletter
  1105. else:
  1106. normal += letter
  1107. WHICH -= 1
  1108. for x in letter:
  1109. if WHICH == 2:
  1110. if letter == "a":
  1111. cletter = SET[(-key_three)% 53]
  1112. normal += cletter
  1113.  
  1114. elif letter == "b":
  1115. cletter = SET[(-key_three+1)% 53]
  1116. normal += cletter
  1117.  
  1118. elif letter == "c":
  1119. cletter = SET[(-key_three+2) % 53]
  1120. normal += cletter
  1121. elif letter == "d":
  1122. cletter = SET[(-key_three+3) % 53]
  1123. normal += cletter
  1124.  
  1125. elif letter == "e":
  1126. cletter = SET[(-key_three+4) % 53]
  1127. normal += cletter
  1128.  
  1129. elif letter == "f":
  1130. cletter = SET[(-key_three+5) % 53]
  1131. normal += cletter
  1132.  
  1133. elif letter == "g":
  1134. cletter = SET[(-key_three+6) % 53]
  1135. normal += cletter
  1136.  
  1137. elif letter == "h":
  1138. cletter = SET[(-key_three+7) % 53]
  1139. normal += cletter
  1140.  
  1141. elif letter == "i":
  1142. cletter = SET[(-key_three+8) % 53]
  1143. normal += cletter
  1144.  
  1145. elif letter == "j":
  1146. cletter = SET[(-key_three+9) % 53]
  1147. normal += cletter
  1148.  
  1149. elif letter == "k":
  1150. cletter = SET[(-key_three+10) % 53]
  1151. normal += cletter
  1152.  
  1153. elif letter == "l":
  1154. cletter = SET[(-key_three+11) % 53]
  1155. normal += cletter
  1156.  
  1157. elif letter == "m":
  1158. cletter = SET[(-key_three+12) % 53]
  1159. normal += cletter
  1160.  
  1161. elif letter == "n":
  1162. cletter = SET[(-key_three+13) % 53]
  1163. normal += cletter
  1164.  
  1165. elif letter == "o":
  1166. cletter = SET[(-key_three+14) % 53]
  1167. normal += cletter
  1168.  
  1169. elif letter == "p":
  1170. cletter = SET[(-key_three+15) % 53]
  1171. normal += cletter
  1172.  
  1173. elif letter == "q":
  1174. cletter = SET[(-key_three+16) % 53]
  1175. normal += cletter
  1176.  
  1177. elif letter == "r":
  1178. cletter = SET[(-key_three+17) % 53]
  1179. normal += cletter
  1180. elif letter == "s":
  1181. cletter = SET[(-key_three+18) % 53]
  1182. normal += cletter
  1183. elif letter == "t":
  1184. cletter = SET[(-key_three+19) % 53]
  1185. normal += cletter
  1186. elif letter == "u":
  1187. cletter = SET[(-key_three+20) % 53]
  1188. normal += cletter
  1189. elif letter == "v":
  1190. cletter = SET[(-key_three+21) % 53]
  1191. normal += cletter
  1192. elif letter == "w":
  1193. cletter = SET[(-key_three+22) % 53]
  1194. normal += cletter
  1195. elif letter == "x":
  1196. cletter = SET[(-key_three+23) % 53]
  1197. normal += cletter
  1198. elif letter == "y":
  1199. cletter = SET[(-key_three+24) % 53]
  1200. normal += cletter
  1201. elif letter == "z":
  1202. cletter = SET[(-key_three+25) % 53]
  1203. normal += cletter
  1204. elif letter == ".":
  1205. cletter = SET[(-key_three+26) % 53]
  1206. normal += cletter
  1207. elif letter == "A":
  1208. cletter = SET [(-key_three + 27) % 53]
  1209. normal += cletter
  1210. elif letter == "B":
  1211. cletter = SET [(-key_three + 28) % 53]
  1212. normal += cletter
  1213. elif letter == "C":
  1214. cletter = SET [(-key_three + 29) % 53]
  1215. normal += cletter
  1216. elif letter == "D":
  1217. cletter = SET [(-key_three + 30) % 53]
  1218. normal += cletter
  1219. elif letter == "E":
  1220. cletter = SET [(-key_three + 31) % 53]
  1221. normal += cletter
  1222. elif letter == "F":
  1223. cletter = SET [(-key_three + 32) % 53]
  1224. normal += cletter
  1225. elif letter == "G":
  1226. cletter = SET [(-key_three + 33) % 53]
  1227. normal += cletter
  1228. elif letter == "H":
  1229. cletter = SET [(-key_three + 34) % 53]
  1230. normal += cletter
  1231. elif letter == "I":
  1232. cletter = SET [(-key_three + 35) % 53]
  1233. normal += cletter
  1234. elif letter == "J":
  1235. cletter = SET [(-key_three + 36) % 53]
  1236. normal += cletter
  1237. elif letter == "K":
  1238. cletter = SET [(-key_three + 37) % 53]
  1239. normal += cletter
  1240. elif letter == "L":
  1241. cletter = SET [(-key_three + 38) % 53]
  1242. normal += cletter
  1243. elif letter == "M":
  1244. cletter = SET [(-key_three + 39) % 53]
  1245. normal += cletter
  1246. elif letter == "N":
  1247. cletter = SET [(-key_three + 40) % 53]
  1248. normal += cletter
  1249. elif letter == "O":
  1250. cletter = SET [(-key_three + 41) % 53]
  1251. normal += cletter
  1252. elif letter == "P":
  1253. cletter = SET [(-key_three + 42) % 53]
  1254. normal += cletter
  1255. elif letter == "Q":
  1256. cletter = SET [(-key_three + 43) % 53]
  1257. normal += cletter
  1258. elif letter == "R":
  1259. cletter = SET [(-key_three + 44) % 53]
  1260. normal += cletter
  1261. elif letter == "S":
  1262. cletter = SET [(-key_three + 45) % 53]
  1263. normal += cletter
  1264. elif letter == "T":
  1265. cletter = SET [(-key_three + 46) % 53]
  1266. normal += cletter
  1267. elif letter == "U":
  1268. cletter = SET [(-key_three + 47) % 53]
  1269. normal += cletter
  1270. elif letter == "V":
  1271. cletter = SET [(-key_three + 48) % 53]
  1272. normal += cletter
  1273. elif letter == "W":
  1274. cletter = SET [(-key_three + 49) % 53]
  1275. normal += cletter
  1276. elif letter == "X":
  1277. cletter = SET [(-key_three + 50) % 53]
  1278. normal += cletter
  1279. elif letter == "Y":
  1280. cletter = SET [(-key_three + 51) % 53]
  1281. normal += cletter
  1282. elif letter == "Z":
  1283. cletter = SET [(-key_three + 52) % 53]
  1284. normal += cletter
  1285. else:
  1286. normal += letter
  1287. WHICH -= 1
  1288. print normal
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296. self.results_plain_text.delete(0.0, END)
  1297. self.results_plain_text.insert(0.0, normal)
  1298.  
  1299.  
  1300. class SETTINGS (Frame):
  1301. def __init__(self,master):
  1302. Frame.__init__(self,master)
  1303. self.grid()
  1304. self.widget()
  1305. self.pack()
  1306. SETTINGS = Toplevel()
  1307. def widget(self):
  1308. self.test = Label (self,
  1309. text = "it works!")
  1310. self.test.grid()
  1311.  
  1312.  
  1313.  
  1314. root = Tk()
  1315. root.title("Coder")
  1316. w, h = root.winfo_screenwidth(), root.winfo_screenheight()
  1317. root.overrideredirect(0)
  1318. root.geometry("%dx%d+0+0" % (w, h))
  1319.  
  1320. app = Application(root)
  1321.  
  1322. root.mainloop()
  1323.  
  1324. print len(SET)
Advertisement
RAW Paste Data Copied
Advertisement