Ejemplo n.º 1
0
def _encrypt(key, plaintext):
    padsize = 16 - (len(key) % 16)
    padded_key = key + ("." * padsize)

    # Pad with "\r" for string shorter than 66 (I don't know why)
    if len(plaintext) < 66:
        padsize = 66 - len(plaintext)
        plaintext += padsize * "\r"

    cipher = aes.encryptData(padded_key, plaintext) 
    cipher_text = base64.encodestring(cipher)
    return cipher_text
Ejemplo n.º 2
0
	if method == 'generate':
		seed = btc.sha256(os.urandom(64))[:32]
		words = old_mnemonic.mn_encode(seed)
		print 'Write down this wallet recovery seed\n\n' + ' '.join(words) + '\n'
	elif method == 'recover':
		words = raw_input('Input 12 word recovery seed: ')
		words = words.split(' ')
		seed = old_mnemonic.mn_decode(words)
		print seed
	password = getpass.getpass('Enter wallet encryption passphrase: ')
	password2 = getpass.getpass('Reenter wallet encryption passphrase: ')
	if password != password2:
		print 'ERROR. Passwords did not match'
		sys.exit(0)
	password_key = btc.bin_dbl_sha256(password)
	encrypted_seed = slowaes.encryptData(password_key, seed.decode('hex'))
	timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
	walletfile = json.dumps({'creator': 'joinmarket project', 'creation_time': timestamp,
		'encrypted_seed': encrypted_seed.encode('hex'), 'network': common.get_network()})
	walletname = raw_input('Input wallet file name (default: wallet.json): ')
	if len(walletname) == 0:
		walletname = 'wallet.json'
	fd = open(os.path.join('wallets', walletname), 'w')
	fd.write(walletfile)
	fd.close()
	print 'saved to ' + walletname
elif method == 'showseed':
	hexseed = wallet.seed
	print 'hexseed = ' + hexseed
	words = old_mnemonic.mn_encode(hexseed)
	print 'Wallet recovery seed\n\n' + ' '.join(words) + '\n'
Ejemplo n.º 3
0
	print 'total balance = %.8fbtc' % (total_balance/1e8)
elif method == 'generate' or method == 'recover':
	if method == 'generate':
		seed = btc.sha256(os.urandom(64))[:32]
		words = old_mnemonic.mn_encode(seed)
		print 'Write down this wallet recovery seed\n\n' + ' '.join(words) + '\n'
	elif method == 'recover':
		words = raw_input('Input 12 word recovery seed: ')
		words = words.split() #default for split is 1 or more whitespace chars
		if len(words) != 12:
			print 'ERROR: Recovery seed phrase must be exactly 12 words.'
			sys.exit(0)
		seed = old_mnemonic.mn_decode(words)
		print seed
	password_key = btc.bin_dbl_sha256(password)
	encrypted_seed = slowaes.encryptData(password_key, seed.decode('hex'))
	timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
	walletfile = json.dumps({'creator': 'joinmarket project', 'creation_time': timestamp,
		'encrypted_seed': encrypted_seed.encode('hex'), 'network': common.get_network()})
	fd = open(os.path.join('wallets', walletname), 'w')
	fd.write(walletfile)
	fd.close()
	print 'saved to ' + walletname
	if password == '':
		print 'without password'
elif method == 'showseed':
	hexseed = wallet.seed
	print 'hexseed = ' + hexseed
	words = old_mnemonic.mn_encode(hexseed)
	print 'Wallet recovery seed\n\n' + ' '.join(words) + '\n'
elif method == 'importprivkey':
Ejemplo n.º 4
0
            words) + '\n'
    elif method == 'recover':
        words = raw_input('Input 12 word recovery seed: ')
        words = words.split()  #default for split is 1 or more whitespace chars
        if len(words) != 12:
            print 'ERROR: Recovery seed phrase must be exactly 12 words.'
            sys.exit(0)
        seed = old_mnemonic.mn_decode(words)
        print seed
    password = getpass.getpass('Enter wallet encryption passphrase: ')
    password2 = getpass.getpass('Reenter wallet encryption passphrase: ')
    if password != password2:
        print 'ERROR. Passwords did not match'
        sys.exit(0)
    password_key = btc.bin_dbl_sha256(password)
    encrypted_seed = slowaes.encryptData(password_key, seed.decode('hex'))
    timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
    walletfile = json.dumps({
        'creator': 'joinmarket project',
        'creation_time': timestamp,
        'encrypted_seed': encrypted_seed.encode('hex'),
        'network': common.get_network()
    })
    walletname = raw_input('Input wallet file name (default: wallet.json): ')
    if len(walletname) == 0:
        walletname = 'wallet.json'
    fd = open(os.path.join('wallets', walletname), 'w')
    fd.write(walletfile)
    fd.close()
    print 'saved to ' + walletname
elif method == 'showseed':
Ejemplo n.º 5
0
        seed = btc.sha256(os.urandom(64))[:32]
        words = old_mnemonic.mn_encode(seed)
        print 'Write down this wallet recovery seed\n\n' + ' '.join(
            words) + '\n'
    elif method == 'recover':
        words = raw_input('Input 12 word recovery seed: ')
        words = words.split(' ')
        seed = old_mnemonic.mn_decode(words)
        print seed
    password = getpass.getpass('Enter wallet encryption passphrase: ')
    password2 = getpass.getpass('Reenter wallet encryption passphrase: ')
    if password != password2:
        print 'ERROR. Passwords did not match'
        sys.exit(0)
    password_key = btc.bin_dbl_sha256(password)
    encrypted_seed = slowaes.encryptData(password_key, seed.decode('hex'))
    timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
    walletfile = json.dumps({
        'creator': 'joinmarket project',
        'creation_time': timestamp,
        'encrypted_seed': encrypted_seed.encode('hex'),
        'network': common.get_network()
    })
    walletname = raw_input('Input wallet file name (default: wallet.json): ')
    if len(walletname) == 0:
        walletname = 'wallet.json'
    fd = open(os.path.join('wallets', walletname), 'w')
    fd.write(walletfile)
    fd.close()
    print 'saved to ' + walletname
elif method == 'showseed':
Ejemplo n.º 6
0
 def encrypt(self, raw):
     return slowaes.encryptData(self.key, raw)