aboutsummaryrefslogtreecommitdiff
path: root/final/RSA.py
diff options
context:
space:
mode:
authorholden watson <holdenew@gmail.com>2019-11-11 21:49:48 -0500
committerholden watson <holdenew@gmail.com>2019-11-11 21:49:48 -0500
commit312ae835a95a0f69cd3ee4480aca50809bc1b1b3 (patch)
treecb9ee8c9480446eada7833d8a46fa2f8a996025a /final/RSA.py
parent399fbca52880871a9a927677275ba754d2874c04 (diff)
parent290603c1d683e63b2e73eebc8f07f3e5386fd9e0 (diff)
Merge branch 'master' of https://github.com/feynmansfedora/appcomb-proj
Diffstat (limited to 'final/RSA.py')
-rw-r--r--final/RSA.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/final/RSA.py b/final/RSA.py
new file mode 100644
index 0000000..c12e94f
--- /dev/null
+++ b/final/RSA.py
@@ -0,0 +1,33 @@
+import random
+def isPrime(x):
+ pr = True
+ for j in range(2, x):
+ if x % j == 0:
+ pr = False
+ return pr
+def remove_char(input_string, index):
+ first_part = input_string[:index]
+ second_part - input_string[index+1:]
+ return first_part + second_part
+primes = [i for i in range(2,1000) if isPrime(i)]
+p = random.choice(primes)
+q = random.choice(primes)
+n = p * q
+print(n)
+string = input()
+sepChars = list(string)
+numChars = 0
+for c in sepChars:
+ numChars += ((128**sepChars.index(c))*ord(c))
+print(numChars)
+blocks = []
+c = 0
+for j in range(0, n-1):
+ blocks.append(str(numChars)[j:j+1])
+for j in range(n-1, len(str(numChars))):
+ blocks[(len(str(n))-1)%j] = blocks[(len(str(n))-1)%j] + str(numChars)[j:j+1]
+
+print(blocks)
+
+
+