Пример #1
0
def send_message(user_info, my_info, message, key):
  # Package
  pay = protocol.write_message(user_info, my_info, message, protocol_version)
  # Encrypt
  enc_pay = saber.encrypt(pay.encode(), 20, key)
  # Convert to string
  str_enc_pay = ''
  for i in range(len(enc_pay)):
    str_enc_pay = str_enc_pay + chr(enc_pay[i])
  # Send payload
  s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
  s.settimeout(TIMEOUT)
  s.connect((user_info[1], port)) # connet() takes tuple (user_ip, port#)
  assert s
  s.send(str_enc_pay.encode()) #encode converts message to bin
  s.shutdown(1)
  s.close()
  return
Пример #2
0
def send_message(user_info, my_info, message, key):
    # Package
    pay = protocol.write_message(user_info, my_info, message, protocol_version)
    # Encrypt
    enc_pay = saber.encrypt(pay.encode(), 20, key)
    # Convert to string
    str_enc_pay = ''
    for i in range(len(enc_pay)):
        str_enc_pay = str_enc_pay + chr(enc_pay[i])
    # Send payload
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(TIMEOUT)
    s.connect((user_info[1], port))  # connet() takes tuple (user_ip, port#)
    assert s
    s.send(str_enc_pay.encode())  #encode converts message to bin
    s.shutdown(1)
    s.close()
    return
Пример #3
0
# License: https://opensource.org/licenses/MIT
# The purpouse of this file is to test, as fully is as reasonable, all
# functions in the TauNet program.

# My Libs
import main, saber, messages, protocol, user_func
# Built in Libs
import time, threading

## saber.py
print("<<<< <<<< <<<< Testing Saber.py >>>> >>>> >>>>")
print("Testing encryption:")
test_string = "1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ `~!@#$%^&*()_+-=[]\{}|;,./<>? '" + '"'
print("Unencrypted Test String: " + test_string)
t_string = [ord(test_string[i]) for i in range(len(test_string))]
enc_test_string = saber.encrypt(t_string, 20, 'password')
print("Testing decryption:")
dec_t_string = saber.decrypt(enc_test_string, 20, 'password')
dec_test_string = ''
for i in range(len(dec_t_string)):
    dec_test_string = dec_test_string + chr(dec_t_string[i])
print("Decrypted Test STring: " + dec_test_string)
test_string = 'Al Dakota buys'
t_string = [ord(test_string[i]) for i in range(len(test_string))]
print("Standardized CipherSaber-2 Test String:\n" + test_string)
dec_t_string = saber.decrypt(t_string, 20, 'Al')
dec_test_string = ''
for i in range(len(dec_t_string)):
    dec_test_string = dec_test_string + chr(dec_t_string[i])
print("mead == " + dec_test_string)
wait = input("[Enter to Contine]")
Пример #4
0
# License: https://opensource.org/licenses/MIT
# The purpouse of this file is to test, as fully is as reasonable, all 
# functions in the TauNet program.

# My Libs
import main, saber, messages, protocol, user_func
# Built in Libs
import time, threading

## saber.py
print("<<<< <<<< <<<< Testing Saber.py >>>> >>>> >>>>")
print("Testing encryption:")
test_string = "1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ `~!@#$%^&*()_+-=[]\{}|;,./<>? '" + '"'
print("Unencrypted Test String: " + test_string)
t_string = [ord(test_string[i]) for i in range(len(test_string))]
enc_test_string = saber.encrypt(t_string, 20, 'password')
print("Testing decryption:")
dec_t_string = saber.decrypt(enc_test_string, 20, 'password')
dec_test_string = ''
for i in range(len(dec_t_string)):
  dec_test_string = dec_test_string + chr(dec_t_string[i])
print("Decrypted Test STring: " + dec_test_string)
test_string = 'Al Dakota buys'
t_string = [ord(test_string[i]) for i in range(len(test_string))]
print("Standardized CipherSaber-2 Test String:\n" + test_string)
dec_t_string = saber.decrypt(t_string, 20, 'Al')
dec_test_string = ''
for i in range(len(dec_t_string)):
  dec_test_string = dec_test_string + chr(dec_t_string[i])
print("mead == " + dec_test_string)
wait = input("[Enter to Contine]")