def main(arguments): """ """ try: pycb = PyCB() print(arguments) if arguments.get('add') is True: print "add remote" elif arguments.get('list') is None: print "list remote" elif arguments.get('remove') is True: print "remove remote" elif arguments.get('search') is True: print "search" keywords = arguments.get('<keyword>') print keywords res = pycb.find(keywords) pycb.printResults(res, False) no = raw_input("Show No: ") pycb.printResult(res, no) var = raw_input("To clipboard? (Y/N) ") if var is "Y" or var is "y": asset = pycb.getAsset(res, no) pyperclip.copy(asset) else: exit(1) except KeyboardInterrupt: print print print "Goodbye! And 'do not cry because it is over, smile because it happened.'"
def main(arguments): """ """ try: pycb = PyCB() print (arguments) if arguments.get('add') is True: print "add remote" elif arguments.get('list') is None: print "list remote" elif arguments.get('remove') is True: print "remove remote" elif arguments.get('search') is True: print "search" keywords = arguments.get('<keyword>') print keywords res = pycb.find(keywords) pycb.printResults(res, False) no = raw_input("Show No: ") pycb.printResult(res, no) var = raw_input("To clipboard? (Y/N) ") if var is "Y" or var is "y": asset = pycb.getAsset(res,no) pyperclip.copy(asset) else: exit(1) except KeyboardInterrupt: print print print "Goodbye! And 'do not cry because it is over, smile because it happened.'"
def copy_to_clipboard(cls, result): """ If the dependent clipboard support is available, copy the result to the system clipboard. :param result: :return: """ try: from pyperclip.pyperclip import copy copy(result) except Exception: pass
def decode(self,key=None,cipher=None): import re try: if key is None and self.key is None: raise Exception("No decryption key provided.") elif key is None and self.key is not None: key=self.key if not re.match(self.regex_pattern, key) and key is not None: raise Exception("Bad decryption key") else: if key is not None: self.key=key.upper() if cipher is not None and not re.match(self.regex_pattern,key): if len(cipher)%5 is 0: self.cipher=cipher.upper() else: print("Invalid ciphertext length. Attempting to use stored value") elif cipher is not None and not cipher.isdigit(): print("Invalid ciphertext. Attempting to use stored value") if self.cipher is not None: # Decrypt factor=self.getFactor() # Bucket the characters in 5 cl=list(self.cipher) cb=list() i=1 t='' for l in cl: t+=str(l) if i%5 is 0: cb.append(t) t='' i+=1 q='' for c in cb: q+=self.mutateLetter(c,factor,False) # rotated inside here self.message=q print(q) try: from pyperclip import pyperclip pyperclip.copy(q) # Copy to clipboard except Exception: print("The value could not be copied to the clipboard.") else: raise Exception("No valid ciphertext to decrypt") except Exception as inst: print("ERROR:", inst) return None
def main(): parser = argparse.ArgumentParser(description="""Invisible Unicode Messages""") parser.add_argument('--text') parser.add_argument('--file') parser.add_argument('--decode') parser.add_argument('--decodef') args = parser.parse_args() from_text = args.text is not None from_file = args.file is not None to_text = args.decode is not None to_file = args.decodef is not None if from_text or from_file: if from_text: encoded = args.text.encode('utf8') elif from_file: with open(args.file, 'rb') as the_file: encoded = the_file.read() hidden = get_hidden_string(encoded) pyperclip.copy(hidden) print('{} invisible characters copied to the clipboard.'.format(len(hidden))) elif to_text or to_file: sourcef = args.decode if to_text else args.decodef with open(sourcef, encoding='utf8') as source: for i, line in enumerate(source): for start, end in find_sequences(line): chunk = line[start:end] if len(chunk)%8 == 0: clear = get_bytes(chunk) if to_text: text = clear.decode('utf8', 'replace') print('l. {:>3} c. {:>3}: {}'.format(i+1, start, text)) elif to_file: basename = os.path.basename(sourcef) filename = '{}.{}.{}'.format(basename, i+1, start) with open(filename, 'wb') as output: output.write(clear) print('file {} created'.format(filename))
def encode(self,key=None,message=None): import re try: if key is None and self.key is None: raise Exception("No encryption key provided.") elif key is None and self.key is not None: key=self.key if not re.match(self.regex_pattern, key) and key is not None: raise Exception("Bad encryption key") else: if key is not None: self.key=key.upper() if message is not None: if re.match(self.regex_pattern, message): # Just valid characters self.message=message.upper() else: # Bad input print("Invalid message or ciphertext, attempting to use stored value") if self.message is not None: factor=self.getFactor() rm=self.rot() mc=list(rm) q='' for c in mc: num=self.mutateLetter(c,factor) q+=num # Deal with the resultant encode self.cipher=q # Store in object print(q) # Display try: from pyperclip import pyperclip pyperclip.copy(q) # Copy to clipboard except Exception: print("The value could not be copied to the clipboard.") else: raise Exception("No valid message to encrypt") except Exception as inst: print("ERROR:", inst) return None
#!/usr/local/bin/env python3 from urllib.parse import urlparse import sys #sys.path.append('/pyperclip-1.5.27') from pyperclip import pyperclip #url = "https://drive.google.com/file/d/0B0HSZQ6LzpOQRlgwckxvNlNubFU/view?usp=sharing" url = sys.argv[1] parsed = urlparse(url) pathlist = parsed.path.split("/") pathlist.remove('') newpath = "/".join(pathlist) #url = parsed.scheme + '://' + parsed.netloc + '/' + newpath if pathlist[0] != 'file': url = 'https://drive.google.com/uc?export=download&id=' + pathlist[4] else: url = 'https://drive.google.com/uc?export=download&id=' + pathlist[2] pyperclip.copy(url) #print(url) quit()
def __init__(self,val=None): # Initialization of class # Do clipboard stuff try: from pyperclip import pyperclip pyperclip.copy('Crytpo Puzzle') p=pyperclip.paste() except Exception as inst: # If we're in Linux, we may need xclip installed import os try: if os.uname()[0] == 'Linux': import yn # From https://gist.github.com/tigerhawkvok/9542594 if not yn.yn("For clipboard functions, xclip is needed. Do you want to install now?"): raise Exception print('Attempting to install the package xclip ...') os.system('sudo apt-get install xclip') try: from pyperclip import pyperclip pyperclip.copy('Crytpo Puzzle') p=pyperclip.paste() except: print('Could not automatically install xclip. Clipboard functions may not work correctly.') else: print('ERROR: Could not enable clipboard functions - ',inst) except: print('Clipboard functions may not work correctly on your setup') try: if os.uname()[0] == 'Linux': print('Please make sure the package "xclip" is installed') except: pass self.key=None try: if val is None: self.cipher=None self.message=None else: # Message is intialized with any value if not re.match(self.regex_hex,val): self.cipher=None if re.match(self.regex_pattern, val): # Just valid characters self.message=val.upper() else: # Bad input print("Invalid message or ciphertext. Initializing empty object.") self.message=None else: # Check padding/encoding if len(val)%3 is 0 or len(val)%5 is 0: self.cipher=val self.message=None else: # All ciphertext characters are legitimate message characters. # Probably a mistake, but make it clear to the user and don't assume. print("Invalid ciphertext length. Initializing as a message.") self.cipher=None self.message=val print("Ready.") except Exception as inst: print("UNEXPECTED ERROR: Could not initialize object -",inst)