示例#1
0
def DoEncodeDecodeB58Checked(msgToEncode, encodedMsg):
    for x in range(1, 10):
        myMsgHash = Nakasendo.MessageHash(msgToEncode)
        encoded = myMsgHash.Base58CheckedEncode()
        if (encoded != encodedMsg):
            print('API ENCODE 58 Checked panic %s is not equal to %s' %
                  (encoded, encodedMsg))
        decoded = myMsgHash.Base58CheckedDecode(encoded)
        if (decoded != msgToEncode):
            print('API DECODE 58 Checked panic %s is not equal to %s' %
                  (encoded, encodedMsg))
示例#2
0
def DoEncodeDecode(msgToEncode, encodedMsg):
    for x in range(1, 10):
        myMsgHash = Nakasendo.MessageHash(msgToEncode)
        encoded = myMsgHash.Base64Encode()
        if (encoded != encodedMsg):
            print('API ENCODE PANIC %s is not equal to %s' %
                  (encoded, encodedMsg))
        #print (encoded)
        decoded = myMsgHash.Bas64Decode(encoded)
        if (decoded != msgToEncode):
            print('API DECODE PANIC %s is not equal to %s' %
                  (decoded, msgToEncode))
示例#3
0
def test_EncodeBase58API(test_data_dir):

    # Reading test data from the file
    with open(test_data_dir / "testData_Encode58Decode",
              "r") as encodeFile_txt:
        for x in encodeFile_txt.readlines():
            encode_Value = x.split(",")
            # Encode given string in base58
            actual_Value = Nakasendo.MessageHash(encode_Value[0])

            # Verifying the actual value with expected value
            assert actual_Value.Base58Encode() == encode_Value[1].rstrip(
                "\n"), "Test failed"
示例#4
0
def test_DecodeBase64API(test_data_dir):

    # Reading test data from the file
    with open(test_data_dir / "testData_Encode64Decode",
              "r") as decodeFile_txt:
        for x in decodeFile_txt.readlines():
            decode_Value = x.split(",")
            # Decode given string in base64
            actual_Value = Nakasendo.MessageHash(decode_Value[1].rstrip("\n"))
            actual_Value = actual_Value.Bas64Decode(
                decode_Value[1].rstrip("\n"))

            # Verifying the actual value with expected value
            assert actual_Value == decode_Value[0], "Test failed"
示例#5
0
def test_EncodeBase58CheckedAPI(test_data_dir):

    # Reading test data from the file
    with open(
            test_data_dir / "testData_Encode58CheckedDecode", "r"
    ) as encode58File_txt:  # Test data were generated using our python interface to encode the input value and decode the output for same input value

        for x in encode58File_txt.readlines():
            encode58_Value = x.split(",")
            # Encode given string in base58
            actual_Value = Nakasendo.MessageHash(encode58_Value[0])

            # Verifying the actual value with expected value
            assert actual_Value.Base58CheckedEncode(
            ) == encode58_Value[1].rstrip("\n"), "Test failed"
示例#6
0
    import Nakasendo
except ImportError as e:
    print('Error while loading SDKLibraries python modules {}'.format(
        e.message))
    print(
        'Try to define environment variable SDKLIBRARIES_ROOT pointing to the location of installed SDKLibraries or add this to PYTHONPATH'
    )
    raise ImportError('Unable to load SDKLibraries python modules')

if __name__ == "__main__":
    print("starting.....")

    print("Testing Base64..Encoding")
    msgToEncode = 'Development team'
    for x in range(1, 10):
        myMsgHash = Nakasendo.MessageHash(msgToEncode)
        encoded = myMsgHash.Base64Encode()
        #print (encoded)
        if (encoded != 'RGV2ZWxvcG1lbnQgdGVhbQ=='):
            print("WEIRDNESS")
        decoded = myMsgHash.Bas64Decode(encoded)
        #print (decoded)
    msgToEncode = 'Research team'
    for x in range(1, 10):
        myMsgHash = Nakasendo.MessageHash(msgToEncode)
        encoded = myMsgHash.Base64Encode()
        #print(encoded)
        if (encoded != 'UmVzZWFyY2ggdGVhbQ=='):
            print('WEIRDNESS')
        decoded = myMsgHash.Bas64Decode(encoded)
        #print(decoded)