当前位置: 首页>>代码示例>>Python>>正文


Python AnonCrypto.random_file方法代码示例

本文整理汇总了Python中anon_crypto.AnonCrypto.random_file方法的典型用法代码示例。如果您正苦于以下问题:Python AnonCrypto.random_file方法的具体用法?Python AnonCrypto.random_file怎么用?Python AnonCrypto.random_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在anon_crypto.AnonCrypto的用法示例。


在下文中一共展示了AnonCrypto.random_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __main__

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import random_file [as 别名]
def __main__(argv):
	min_key_len = 1024

	if(len(argv) != 14):
		raise ValueError, "Usage: %s id key_len round_id n_nodes my_ip my_port leader_ip leader_port dnstr_ip dnstr_port upstr_ip upstr_port msg_len" % (argv[0])

	logger = logging.getLogger()
	logger.setLevel(logging.DEBUG)
	debug("Starting node")

	id = int(argv[1])
	key_len = int(argv[2])
	round_id = int(argv[3])
	n_nodes = int(argv[4])
	my_addr = (argv[5], int(argv[6]))
	leader_addr = (argv[7], int(argv[8]))
	up_addr = (argv[9], int(argv[10]))
	dn_addr = (argv[11], int(argv[12]))
	msg_len = int(argv[13])

	msg_file = AnonCrypto.random_file(msg_len)

	node = bulk_node.bulk_node(id, key_len, round_id, n_nodes,
			my_addr, leader_addr, up_addr, dn_addr, msg_file)
	cProfile.runctx('mynode.run_protocol()', {'mynode': node}, {})
#node.run_protocol()
	fnames = node.output_filenames()

	for i in xrange(0, len(fnames)):
		copyfile(fnames[i], "data/node%04d-%04d.out" % (id, i))

	return
开发者ID:ASchurman,项目名称:Dissent,代码行数:34,代码来源:run_bulk.py

示例2: __main__

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import random_file [as 别名]
def __main__(argv):
	min_key_len = 1024

	if(len(argv) != 16):
		raise ValueError, "Usage: %s id key_len round_id n_nodes my_ip my_port leader_ip leader_port dnstr_ip dnstr_port upstr_ip upstr_port msg_len max_len mode" % (argv[0])

	logger = logging.getLogger()
	logger.setLevel(logging.DEBUG)

	id = int(argv[1])
	key_len = int(argv[2])
	round_id = int(argv[3])
	n_nodes = int(argv[4])
	my_addr = (argv[5], int(argv[6]))
	leader_addr = (argv[7], int(argv[8]))
	up_addr = (argv[9], int(argv[10]))
	dn_addr = (argv[11], int(argv[12]))
	msg_len = int(argv[13])
	max_len = int(argv[14])
	mode = int (argv[15])
	
	msg_file = AnonCrypto.random_file(msg_len)
	node = shuffle_node.shuffle_node(id, key_len, round_id, n_nodes,
			my_addr, leader_addr, up_addr, dn_addr, msg_file, max_len)
	
#cProfile.runctx('node.run_protocol()', {}, {'node': node})
	node.run_bad_protocol(mode)
	fnames = node.output_filenames()
	print "--------------------------------------------------------------------"
#	for i in xrange(0, len(fnames)):
#		copyfile(fnames[i], "data/node%04d-%04d.out" % (id, i))

	return
开发者ID:ASchurman,项目名称:Dissent,代码行数:35,代码来源:run_bad_shuffle.py

示例3: start_node

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import random_file [as 别名]
    def start_node(self, down_index, up_index, participants_vector, my_id):
        n_nodes = len(participants_vector)
        leader_addr = (participants_vector[0][1], int(participants_vector[0][3]))
        my_addr = (participants_vector[my_id][1], int(participants_vector[my_id][3]))
        dn_addr = (participants_vector[down_index][1], int(participants_vector[down_index][3]))
        up_addr = (participants_vector[up_index][1], int(participants_vector[up_index][3]))
        round_id = 1
        key_len = KEY_LENGTH

        """ if distrusted peer is participating, then don't share file (if one is chosen) """
        self.DEBUG("Distrusted peers: %s" % self.distrusted_peers)
        msg_file = None
        trusted = True
        if os.path.exists(self.shared_filename):
            for peer in participants_vector:
                for distrusted_peer in self.distrusted_peers:
                    (d_ip, d_port) = distrusted_peer
                    (p_ip, p_port) = peer[1], peer[2]
                    if d_ip == p_ip and str(d_port) == str(p_port):
                        self.DEBUG("Not sharing my file because peer %s:%s is participating" % (p_ip, p_port))
                        trusted = False
                        break
                if not trusted:
                    break

        # create random file if none has been shared
        if trusted and os.path.exists(self.shared_filename):
            msg_file = self.shared_filename
        else:
            msg_file = AnonCrypto.random_file(DEFAULT_LENGTH)

        # initialize node
        self.node = bulk_node.bulk_node(
            my_id,
            key_len,
            round_id,
            n_nodes,
            my_addr,
            leader_addr,
            dn_addr,
            up_addr,
            msg_file,
            participants_vector,
            self.privgenkey1,
            self.privgenkey2,
        )
        self.DEBUG(
            "round_id: %s id: %s n_nodes: %s my_addr: %s leader_addr: %s dn_addr: %s up_addr: %s msg_file: %s"
            % (round_id, my_id, n_nodes, my_addr, leader_addr, dn_addr, up_addr, msg_file)
        )
开发者ID:nya2,项目名称:Dissent-TCP-communication,代码行数:52,代码来源:net.py


注:本文中的anon_crypto.AnonCrypto.random_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。