1
0

new commands: encrypt and decrypt messages

This commit is contained in:
ThomasV
2014-01-30 14:43:46 +01:00
parent ae3cb372c8
commit 631c967df9
2 changed files with 15 additions and 5 deletions

View File

@@ -95,6 +95,8 @@ register_command('signmessage', 2,-1, False, True, True, 'Sign a mess
register_command('unfreeze', 1, 1, False, True, False, 'Unfreeze the funds at one of your wallet\'s address', 'unfreeze <address>')
register_command('validateaddress', 1, 1, False, False, False, 'Check that the address is valid', 'validateaddress <address>')
register_command('verifymessage', 3,-1, False, False, False, 'Verifies a signature', verifymessage_syntax)
register_command('encrypt', 2,-1, False, False, False, 'encrypt a message with pubkey')
register_command('decrypt', 2,-1, False, False, False, 'decrypt a message with privkey')
register_command('daemon', 1, 1, True, False, False, 'start/stop daemon')
register_command('getproof', 1, 1, True, False, False, 'start/stop daemon')
@@ -390,5 +392,13 @@ class Commands:
else:
return "unknown transaction"
def encrypt(self, pubkey, message):
return EC_KEY.encrypt_message(message, pubkey.decode('hex'))
def decrypt(self, private_key, message):
eck = EC_KEY(private_key.decode('hex'))
decrypted = eck.decrypt_message(message)
return decrypted[0]