diff --git a/onionr/communicator.py b/onionr/communicator.py index b10317fc..1b4b061e 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -53,7 +53,7 @@ class OnionrCommunicate: highFailureRate = 10 heartBeatTimer = 0 heartBeatRate = 5 - pexTimer = 5 # How often we should check for new peers + pexTimer = 10 # How often we should check for new peers pexCount = 0 logger.debug('Communicator debugging enabled.') torID = open('data/hs/hostname').read() @@ -223,7 +223,6 @@ class OnionrCommunicate: ''' URL encodes the data ''' - return urllib.parse.quote_plus(data) def performGet(self, action, peer, data=None, skipHighFailureAddress=False, peerType='tor'): diff --git a/onionr/cryptotests.py b/onionr/cryptotests.py new file mode 100755 index 00000000..036d5fb0 --- /dev/null +++ b/onionr/cryptotests.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +''' + Onionr - P2P Microblogging Platform & Social network + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +''' +import unittest, sys, os, core, onionrcrypto, logger + +class OnionrCryptoTests(unittest.TestCase): + def testSymmetric(self): + dataString = "this is a secret message" + dataBytes = dataString.encode() + myCore = core.Core() + crypto = onionrcrypto.OnionrCrypto(myCore) + key = key = b"tttttttttttttttttttttttttttttttt" + + logger.info("Encrypting: " + dataString) + encrypted = crypto.symmetricEncrypt(dataString, key, returnEncoded=True) + logger.info(encrypted) + logger.info('Decrypting encrypted string:') + decrypted = crypto.symmetricDecrypt(encrypted, key, encodedMessage=True) + logger.info(decrypted) + self.assertTrue(True) +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index c82a39e2..1d0c370b 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -18,7 +18,7 @@ along with this program. If not, see . ''' # Misc functions that do not fit in the main api, but are useful -import getpass, sys, requests, os, socket, hashlib, logger, sqlite3, config +import getpass, sys, requests, os, socket, hashlib, logger, sqlite3, config, binascii import nacl.signing, nacl.encoding if sys.version_info < (3, 6): @@ -190,6 +190,8 @@ class OnionrUtils: nacl.signing.SigningKey(seed=key, encoder=nacl.encoding.Base32Encoder) except nacl.exceptions.ValueError: pass + except binascii.Error: + pass else: retVal = True return retVal