cryptocalypse commited on
Commit
d7992f6
1 Parent(s): b28bf87
Files changed (2) hide show
  1. app.py +8 -3
  2. lib/ziruph.py +36 -0
app.py CHANGED
@@ -3,11 +3,15 @@ from huggingface_hub import InferenceClient
3
  from lib.gematria import calculate_gematria, strip_diacritics
4
  from lib.temuraeh import temura_conv
5
  from lib.notarikon import notarikon
 
6
 
7
  from torahcodes.resources.func.torah import *
 
 
8
  torah = Torah()
9
  books.load()
10
  booklist=books.booklist()
 
11
  try:
12
  bk = booklist[0]
13
  print(torah.gematria_sum("בפומט"))
@@ -32,7 +36,8 @@ def temurae(textA,lang):
32
 
33
  def ziruph(dic,text):
34
 
35
- return (notarikon(text,"first"),notarikon(text,"last"))
 
36
 
37
  def gematria_sum(text):
38
  els_space = torah.gematria_sum(text)
@@ -161,14 +166,14 @@ with gr.Blocks(title="Sophia, Torah Codes") as demo:
161
  dictionary_zir=gr.Dropdown(
162
  ["Kircher", "Random", "Custom"],value="Latin",scale=1, label="Ziruph Dictionary", info="Choose ziruph dictionary"
163
  ),
164
- custom_dic = gr.Textbox(label="Custom Dictionary",scale=3)
165
  zir_btn = gr.Button("Encrypt",scale=1)
166
  with gr.Row():
167
  zir_result = gr.Textbox(label="Results")
168
 
169
  zir_btn.click(
170
  ziruph,
171
- inputs=[zir_text,zir_text],
172
  outputs=zir_result
173
  )
174
 
 
3
  from lib.gematria import calculate_gematria, strip_diacritics
4
  from lib.temuraeh import temura_conv
5
  from lib.notarikon import notarikon
6
+ from lib.ziruph import encrypt,decrypt
7
 
8
  from torahcodes.resources.func.torah import *
9
+
10
+
11
  torah = Torah()
12
  books.load()
13
  booklist=books.booklist()
14
+
15
  try:
16
  bk = booklist[0]
17
  print(torah.gematria_sum("בפומט"))
 
36
 
37
  def ziruph(dic,text):
38
 
39
+ return encrypt(text,dic)
40
+
41
 
42
  def gematria_sum(text):
43
  els_space = torah.gematria_sum(text)
 
166
  dictionary_zir=gr.Dropdown(
167
  ["Kircher", "Random", "Custom"],value="Latin",scale=1, label="Ziruph Dictionary", info="Choose ziruph dictionary"
168
  ),
169
+ custom_dic = gr.Textbox(value="C X Y B W P R V Q J Z M N T K E L D F G H I O U S",label="Custom Dictionary",scale=3)
170
  zir_btn = gr.Button("Encrypt",scale=1)
171
  with gr.Row():
172
  zir_result = gr.Textbox(label="Results")
173
 
174
  zir_btn.click(
175
  ziruph,
176
+ inputs=[zir_text,custom_dic],
177
  outputs=zir_result
178
  )
179
 
lib/ziruph.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+ # Define the substitution key
5
+ key = "C X Y B W P R V Q J Z M N T K E L D F G H I O U S"
6
+
7
+ # Define the plaintext and ciphertext functions
8
+ def encrypt(message,dic):
9
+ ciphertext = ""
10
+ for char in message:
11
+ if char.isalpha():
12
+ # Check if char is uppercase or lowercase
13
+ if char.isupper():
14
+ # Convert to lowercase and encrypt using key
15
+ encrypted = key[ord(char) - ord("A")].lower()
16
+ else:
17
+ # Convert to uppercase and encrypt using key
18
+ encrypted = key[ord(char) - ord("a")].upper()
19
+ ciphertext += encrypted
20
+ return ciphertext
21
+
22
+ def decrypt(message,dic):
23
+ plaintext = ""
24
+ for char in message:
25
+ if char.isalpha():
26
+ # Check if char is uppercase or lowercase
27
+ if char.isupper():
28
+ # Convert to lowercase and decrypt using inverse key
29
+ decrypted = key[25 - key.index(char.lower())].upper()
30
+ else:
31
+ # Convert to uppercase and decrypt using inverse key
32
+ decrypted = key[25 - key.index(char)].lower()
33
+ plaintext += decrypted
34
+ return plaintext
35
+
36
+