Python random.init_from_bin() Examples

The following are code examples for showing how to use random.init_from_bin(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: ssrr   Author: do21   File: auth_chain.py    (license) View Source Project 6 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list:
            self.data_size_list = []
            self.data_size_list2 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        # ??????4~12-1
        list_len = random.next() % 8 + 4
        for i in range(0, list_len):
            self.data_size_list.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list.sort()
        # ??????8~24-1
        list_len = random.next() % 16 + 8
        for i in range(0, list_len):
            self.data_size_list2.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list2.sort() 
Example 2
Project: luci-oso21   Author: oso21   File: auth_chain.py    (license) View Source Project 6 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list:
            self.data_size_list = []
            self.data_size_list2 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        # ??????4~12-1
        list_len = random.next() % 8 + 4
        for i in range(0, list_len):
            self.data_size_list.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list.sort()
        # ??????8~24-1
        list_len = random.next() % 16 + 8
        for i in range(0, list_len):
            self.data_size_list2.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list2.sort() 
Example 3
Project: shadowsocksR-b   Author: hao35954514   File: auth_chain.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 4
Project: shadowsocksR-b   Author: hao35954514   File: auth_chain.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 5
Project: ssrr   Author: do21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 6
Project: ssrr   Author: do21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 7
Project: ssrr   Author: do21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list0:
            self.data_size_list0 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        # ??????12~24-1
        list_len = random.next() % (8 + 16) + (4 + 8)
        for i in range(0, list_len):
            self.data_size_list0.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list0.sort() 
Example 8
Project: ssrr   Author: do21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list0:
            self.data_size_list0 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        # ??????12~24-1
        list_len = random.next() % (8 + 16) + (4 + 8)
        for i in range(0, list_len):
            self.data_size_list0.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list0.sort()
        old_len = len(self.data_size_list0)
        self.check_and_patch_data_size(random)
        # if check_and_patch_data_size are work, re-sort again.
        if old_len != len(self.data_size_list0):
            self.data_size_list0.sort() 
Example 9
Project: shadowsocksr-python   Author: nanqinlang-shadowsocksr   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 10
Project: shadowsocksr-python   Author: nanqinlang-shadowsocksr   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 11
Project: shadowsocksr-python   Author: nanqinlang-shadowsocksr   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list:
            self.data_size_list = []
            self.data_size_list2 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        list_len = random.next() % 8 + 4
        for i in range(0, list_len):
            self.data_size_list.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list.sort()
        list_len = random.next() % 16 + 8
        for i in range(0, list_len):
            self.data_size_list2.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list2.sort() 
Example 12
Project: luci-oso21   Author: oso21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 13
Project: luci-oso21   Author: oso21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 14
Project: luci-oso21   Author: oso21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list0:
            self.data_size_list0 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        # ??????12~24-1
        list_len = random.next() % (8 + 16) + (4 + 8)
        for i in range(0, list_len):
            self.data_size_list0.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list0.sort() 
Example 15
Project: luci-oso21   Author: oso21   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list0:
            self.data_size_list0 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        # ??????12~24-1
        list_len = random.next() % (8 + 16) + (4 + 8)
        for i in range(0, list_len):
            self.data_size_list0.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list0.sort()
        old_len = len(self.data_size_list0)
        self.check_and_patch_data_size(random)
        # if check_and_patch_data_size are work, re-sort again.
        if old_len != len(self.data_size_list0):
            self.data_size_list0.sort() 
Example 16
Project: shadowsocksr   Author: emacsenli   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 17
Project: shadowsocksr   Author: emacsenli   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 18
Project: shadowsocksrh   Author: hhhizzz   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 19
Project: shadowsocksrh   Author: hhhizzz   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 20
Project: ShadowSocksShare-OpenShift   Author: the0demiurge   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_from_bin(self, bin):
        bin += b'\0' * 16
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0] 
Example 21
Project: ShadowSocksShare-OpenShift   Author: the0demiurge   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def udp_rnd_data_len(self, last_hash, random):
        random.init_from_bin(last_hash)
        return random.next() % 127 
Example 22
Project: ShadowSocksShare-OpenShift   Author: the0demiurge   File: auth_chain.py    (license) View Source Project 5 votes vote down vote up
def init_data_size(self, key):
        if self.data_size_list:
            self.data_size_list = []
            self.data_size_list2 = []
        random = xorshift128plus()
        random.init_from_bin(key)
        list_len = random.next() % 8 + 4
        for i in range(0, list_len):
            self.data_size_list.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list.sort()
        list_len = random.next() % 16 + 8
        for i in range(0, list_len):
            self.data_size_list2.append((int)(random.next() % 2340 % 2040 % 1440))
        self.data_size_list2.sort()