py3 quality fixes
This commit is contained in:
parent
d68085869b
commit
55085af208
|
@ -16,7 +16,9 @@ def makeCryptor(privkey):
|
||||||
private_key = a.changebase(privkey, 16, 256, minlen=32)
|
private_key = a.changebase(privkey, 16, 256, minlen=32)
|
||||||
public_key = pointMult(private_key)
|
public_key = pointMult(private_key)
|
||||||
privkey_bin = '\x02\xca\x00\x20'.encode('raw_unicode_escape') + private_key
|
privkey_bin = '\x02\xca\x00\x20'.encode('raw_unicode_escape') + private_key
|
||||||
pubkey_bin = '\x02\xca\x00\x20'.encode('raw_unicode_escape') + public_key[1:-32] + '\x00\x20'.encode('utf-8') + public_key[-32:]
|
pubkey_bin = '\x02\xca\x00\x20'.encode(
|
||||||
|
'raw_unicode_escape') + public_key[1:-32] + '\x00\x20'.encode(
|
||||||
|
'utf-8') + public_key[-32:]
|
||||||
cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin)
|
cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin)
|
||||||
return cryptor
|
return cryptor
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
0# pylint: disable=missing-docstring,too-many-function-args
|
# pylint: disable=missing-docstring,too-many-function-args
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import re
|
import re
|
||||||
|
@ -30,7 +30,7 @@ def get_code_string(base):
|
||||||
elif base == 58:
|
elif base == 58:
|
||||||
return "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
return "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||||
elif base == 256:
|
elif base == 256:
|
||||||
'''raw_unicode_escape is used because in the python3 after range(161) its genreate the'
|
'''raw_unicode_escape is used because in the python3 after range(161) its genreate
|
||||||
the speical character so avoiding that function we have used the raw_unicode method '''
|
the speical character so avoiding that function we have used the raw_unicode method '''
|
||||||
return bytes(range(0, 256))
|
return bytes(range(0, 256))
|
||||||
else:
|
else:
|
||||||
|
@ -39,7 +39,7 @@ def get_code_string(base):
|
||||||
|
|
||||||
def encode(val, base, minlen=0):
|
def encode(val, base, minlen=0):
|
||||||
code_string = get_code_string(base)
|
code_string = get_code_string(base)
|
||||||
result = str.encode('') if type(code_string) == bytes else ''
|
result = str.encode('') if type(code_string) is bytes else ''
|
||||||
while val > 0:
|
while val > 0:
|
||||||
result = code_string[val % base:val % base + 1] + result
|
result = code_string[val % base:val % base + 1] + result
|
||||||
val = val // base
|
val = val // base
|
||||||
|
@ -47,6 +47,7 @@ def encode(val, base, minlen=0):
|
||||||
result = code_string[0] * (minlen - len(result)) + result
|
result = code_string[0] * (minlen - len(result)) + result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def decode(string, base):
|
def decode(string, base):
|
||||||
code_string = get_code_string(base)
|
code_string = get_code_string(base)
|
||||||
result = 0
|
result = 0
|
||||||
|
|
|
@ -679,7 +679,7 @@ def loadOpenSSL():
|
||||||
path.join(sys._MEIPASS, 'libssl.so'),
|
path.join(sys._MEIPASS, 'libssl.so'),
|
||||||
path.join(sys._MEIPASS, 'libcrypto.so.1.1.0'),
|
path.join(sys._MEIPASS, 'libcrypto.so.1.1.0'),
|
||||||
path.join(sys._MEIPASS, 'libssl.so.1.1.0'),
|
path.join(sys._MEIPASS, 'libssl.so.1.1.0'),
|
||||||
path.join(sys._MEIPASS, 'libcrypto.so.1.0.2'),
|
path.join(sys._MEIPASS, 'libcrypto.so.1.0.2'),
|
||||||
path.join(sys._MEIPASS, 'libssl.so.1.0.2'),
|
path.join(sys._MEIPASS, 'libssl.so.1.0.2'),
|
||||||
path.join(sys._MEIPASS, 'libcrypto.so.1.0.1'),
|
path.join(sys._MEIPASS, 'libcrypto.so.1.0.1'),
|
||||||
path.join(sys._MEIPASS, 'libssl.so.1.0.1'),
|
path.join(sys._MEIPASS, 'libssl.so.1.0.1'),
|
||||||
|
|
|
@ -89,6 +89,7 @@ def isAddressInMyAddressBookSubscriptionsListOrWhitelist(address):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def decodeWalletImportFormat(WIFstring):
|
def decodeWalletImportFormat(WIFstring):
|
||||||
fullString = arithmetic.changebase(WIFstring, 58, 256)
|
fullString = arithmetic.changebase(WIFstring, 58, 256)
|
||||||
privkey = fullString[:-4]
|
privkey = fullString[:-4]
|
||||||
|
@ -171,8 +172,9 @@ def reloadBroadcastSendersForWhichImWatching():
|
||||||
# we should create Cryptor objects in a dictionary which we will
|
# we should create Cryptor objects in a dictionary which we will
|
||||||
# use to attempt to decrypt encrypted broadcast messages.
|
# use to attempt to decrypt encrypted broadcast messages.
|
||||||
if addressVersionNumber <= 3:
|
if addressVersionNumber <= 3:
|
||||||
privEncryptionKey = hashlib.sha512((encodeVarint(addressVersionNumber) \
|
privEncryptionKey = hashlib.sha512((
|
||||||
+ encodeVarint(streamNumber) + hash)).digest()[:32]
|
encodeVarint(addressVersionNumber) +
|
||||||
|
encodeVarint(streamNumber) + hash)).digest()[:32]
|
||||||
MyECSubscriptionCryptorObjects[hash] = \
|
MyECSubscriptionCryptorObjects[hash] = \
|
||||||
highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))
|
highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))
|
||||||
else:
|
else:
|
||||||
|
@ -191,8 +193,8 @@ def fixPotentiallyInvalidUTF8Data(text):
|
||||||
unicode(text, 'utf-8')
|
unicode(text, 'utf-8')
|
||||||
return text
|
return text
|
||||||
except:
|
except:
|
||||||
return 'Part of the message is corrupt. The message cannot be' \
|
return 'Part of the message is corrupt. The message cannot be'\
|
||||||
' displayed the normal way.\n\n' + repr(text)
|
' displayed the normal way.\n\n' + repr(text)
|
||||||
|
|
||||||
|
|
||||||
# Checks sensitive file permissions for inappropriate umask
|
# Checks sensitive file permissions for inappropriate umask
|
||||||
|
|
Reference in New Issue
Block a user