Skip to content

Instantly share code, notes, and snippets.

@james-see
Created January 12, 2015 18:36
Show Gist options
  • Save james-see/0071481fd40fd5b5777a to your computer and use it in GitHub Desktop.
Save james-see/0071481fd40fd5b5777a to your computer and use it in GitHub Desktop.
pyen.py
# this script takes a 26 char string that you provide and
# a phrase and turns it into a cipher
# it works in pythonista
import random
import sys
import string
import console
import clipboard
import webbrowser
#functions
#this function gets inputs with custom prompts
def inputer(prompt):
value = None
while value is None:
try:
value = raw_input(prompt)
except ValueError:
print 'Please enter a tag'
value = None
return value
#get pinboard tag of interest
cipher = inputer("what is your string?: ")
phrased = inputer("What is your phrase?: ")
#GLOBALS
alphastring = string.ascii_lowercase
alphalist = list(string.ascii_lowercase)
cipherstring = cipher
example = phrased
if example == "":
example = "hello"
ouput = ''
i = 0
convertnum = []
encrypted = []
for ch in example:
convertnum.append(str(alphastring.index(ch[i])))
#print (convertnum)
print ''.join(cipherstring)
for cy in convertnum:
encrypted.append(cipherstring[int(cy)])
#print cipherstring[int(cy)]
encrypted = ''.join(encrypted)
print encrypted
clipboard.set(encrypted)
webbrowser.open('workflow://')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment