def cmd_key(opts, args, overDict): if len(args) == 2: if args[1] == 'copy': from crypt import key TextToSave = my_id.getLocalID() + "\n" + key.MyPrivateKey() misc.setClipboardText(TextToSave) print 'now you can "paste" with Ctr+V your private key where you want.' del TextToSave return 0 elif args[1] == 'print': from crypt import key TextToSave = my_id.getLocalID() + "\n" + key.MyPrivateKey() print print TextToSave return 0 elif len(args) == 3: if args[1] == 'copy': filenameto = args[2] from crypt import key TextToSave = my_id.getLocalID() + "\n" + key.MyPrivateKey() if not bpio.AtomicWriteFile(filenameto, TextToSave): print 'error writing to', filenameto return 1 print 'your private key were copied to file %s' % filenameto del TextToSave return 0 return 2
def cmd_key(opts, args, overDict, running, executablePath): from main import settings from lib import misc from system import bpio from userid import my_id from crypt import key settings.init() my_id.init() if not key.LoadMyKey(): print_text('private key not exist or is not valid\n') return 0 if not my_id.isLocalIdentityReady(): print_text('local identity not exist, your key worth nothing\n') return 0 if len(args) == 2: if args[1] == 'copy': TextToSave = my_id.getLocalID() + "\n" + key.MyPrivateKey() misc.setClipboardText(TextToSave) del TextToSave print_text('now you can "paste" with Ctr+V your private key where you want') print_text('WARNING! keep your key in safe place, do not publish it!\n') return 0 elif args[1] == 'print': TextToSave = my_id.getLocalID() + "\n" + key.MyPrivateKey() print_text('\n' + TextToSave + '\n') del TextToSave print_text('WARNING! keep your key in safe place, do not publish it!\n') return 0 elif len(args) == 3: if args[1] == 'copy' or args[1] == 'save' or args[1] == 'backup': from system import bpio curpath = os.getcwd() os.chdir(executablePath) filenameto = bpio.portablePath(args[2]) os.chdir(curpath) TextToSave = my_id.getLocalID() + "\n" + key.MyPrivateKey() if not bpio.AtomicWriteFile(filenameto, TextToSave): del TextToSave print_text('error writing to %s\n' % filenameto) return 1 del TextToSave print_text('your private key were copied to file %s' % filenameto) print_text('WARNING! keep your key in safe place, do not publish it!\n') return 0 return 2