示例#1
0
def add(a, b):
    c = ""
    a = util.hex_to_bin(a)
    b = util.hex_to_bin(b)
    c = util.xor(a, b)
    c = util.bin_to_hex(c)
    return c
示例#2
0
def ARK(message, key):
    new_message = ""
    message = util.hex_to_bin(message)
    key = util.hex_to_bin(key)
    new_message = util.xor(message, key)
    new_message = util.bin_to_hex(new_message)
    return new_message
示例#3
0
class Darkcoin(coin.Coin):
    name = 'darkcoin'

    symbols = ['DRK']
    symbol = symbols[0]

    # https://github.com/darkcoinproject/darkcoin/blob/master/src/net.cpp#L1195
    dns_seeds = [
        ("23.23.186.131", 9333),
        ("162.252.83.46", 9333),
        ("107.155.71.72", 9333),
        ("50.16.206.102", 9333),
        ("50.19.116.123", 9333),
        ("98.165.130.67", 9333),
        ("23.23.186.131", 9333),
        ("50.16.206.102", 9333),
        ("50.19.116.123", 9333),
        ("50.19.116.123", 9333),
        ("23.21.204.34", 9333),
        ("188.142.39.105", 9333),
        ("50.16.206.102", 9333),
        ("23.23.186.131", 9333),
        ("50.19.116.123", 9333),
        ("54.248.227.151", 9333),
        ("42.121.58.91", 9333),
        ("50.81.192.39", 9333),
        ("54.193.124.32", 9333),
        ("62.141.39.175", 9333),
        ("5.254.96.3", 9333),
        ("175.115.201.44", 9333),
        ("208.53.191.2", 9333),
        ("162.243.33.16", 9333),
    ]

    port = 9333

    genesis_version = 2
    genesis_block_hash = util.hex_to_bin(
        '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6')
    genesis_merkle_root = util.hex_to_bin(
        'e0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7')
    genesis_timestamp = 1390103681
    genesis_nonce = 128987

    # https://github.com/darkcoinproject/darkcoin/blob/master/src/protocol.cpp#L26
    magic = "\xbf\x0c\x6b\xbd"

    address_version = chr(76)
示例#4
0
def main():

    address_hex, block_num, set_size, block_size = get_user_input()

    address_bin = hex_to_bin(address_hex)

    print("\nThe address you entered is {} (binary {})\
        ".format(address_hex, address_bin))

    print(
        "\nNumber of blocks: {}\t Size of each set: {}\t Size of each block: {}\
        ".format(block_num, set_size, block_size))

    address_len = len(address_bin)
    index_len = get_index_len(block_num, set_size)
    offset_len = get_offset_len(block_size)
    tag_len = get_tag_len(address_len, index_len, offset_len)

    address_tag, address_index, address_offset = partition_addr(
        address_bin, tag_len, index_len, offset_len)

    address_tag_hex, address_index_hex, address_offset_hex = batch_bin_to_hex(
        address_tag, address_index, address_offset)

    print('\nTag (bin) is\t\t{}\nIndex (bin) is\t\t{}\nOffset (bin) is\t\t{}\
        '.format(address_tag, address_index, address_offset))

    print('\nTag (hex) is\t\t{}\nIndex (hex) is\t\t{}\nOffset (hex) is\t\t{}\
        '.format(address_tag_hex, address_index_hex, address_offset_hex))
def handle_s2b_plogin(line):
    global curlogins

    pid, flag, name, pw, ip, macid, contid = line.split(':')

    pid = int(pid)
    flag = int(flag)
    macid = long(macid)

    if curlogins >= maxlogins:
        send_b2s_pbad(
            pid,
            'The server is currently busy processing other login requests, please try again in a few moments.'
        )
        return

    curlogins = curlogins + 1

    if contid:
        contid = util.hex_to_bin(contid)

    log("player login: " + name)

    vie_bprot.send_s2b_playerlogin(flag, inet_aton(ip), name, pw, pid, macid,
                                   0, contid)
示例#6
0
    def __init__(self, address, offset, index_size):
        # Calculate address slices
        offset_start = 32 - offset
        index_start = offset_start - index_size

        # Convert address to binary string
        binary_string = util.hex_to_bin(address)

        self._tag = binary_string[0:index_start]
        self._index = binary_string[index_start:offset_start]
        self._offset = binary_string[offset_start:32]
示例#7
0
def handle_s2b_plogin(line):
	global curlogins

	pid, flag, name, pw, ip, macid, contid = line.split(':')

	pid = int(pid)
	flag = int(flag)
	macid = long(macid)

	if curlogins >= maxlogins:
		send_b2s_pbad(pid, 'The server is currently busy processing other login requests, please try again in a few moments.')
		return

	curlogins = curlogins + 1

	if contid:
		contid = util.hex_to_bin(contid)

	log("player login: " + name)

	vie_bprot.send_s2b_playerlogin(flag, inet_aton(ip), name, pw, pid,
		macid, 0, contid)
示例#8
0
def main():
    address_hex, page_size = get_user_input()
    address_bin = hex_to_bin(address_hex)

    offset_len = get_offset_len(page_size)
    vpn_len = get_vpn_len(address_bin, offset_len)

    addr_vpn = get_vpn(address_bin, vpn_len)
    addr_vpo = get_vpo(address_bin, vpn_len)

    addr_vpn_hex = bin_to_hex(addr_vpn)
    addr_vpo_hex = bin_to_hex(addr_vpo)

    print("\nThe Virtual Page Number of your address is {}\n\
        ".format(addr_vpn))
    print("The Virtual Page Offset of your address is {}\n\
        ".format(addr_vpo))

    print("\nThe Virtual Page Number of your address in hex is {}\n\
        ".format(addr_vpn_hex))
    print("The Virtual Page Offset of your address in hex is {}\n\
        ".format(addr_vpo_hex))
示例#9
0
    for i in range(2**m):
        c = str(int(util.dec_to_bin(i)))
        c = ("0" * (m - len(c))) + c
        ms.append(c)
    for i in range(2**m):
        ni = 0
        for j in range(k):
            sub_bits = bits[j * m:j * m + m]
            if sub_bits == ms[i]:
                ni += 1
        ns.append(ni)
    for i in range(2**m):
        x += ns[i]**2
    x = ((2**m) / k) * x
    x = x - k
    return x


def corridos():
    return 0


def autocorrelation_test():
    return 0


s = "e3114ef249e3114ef249e3114ef249e3114ef249"
s = util.hex_to_bin(s)
print(frecuency_test(s))
print(serial_test(s))
print(poker_test(s, 3))