MCPcopy Create free account
hub / github.com/ActiveState/code / new

Method new

recipes/Python/578075_Markov_Encryption_Module/recipe-578075.py:50–60  ·  view source on GitHub ↗

Return a Key instance created from bytes_used and chain_size. Creating a new key is easy with this method. Call this class method with the bytes you want the key to recognize along with the size of the chains you want the encryption/decryption processes to use.

(cls, bytes_used, chain_size)

Source from the content-addressed store, hash-verified

48
49 @classmethod
50 def new(cls, bytes_used, chain_size):
51 """Return a Key instance created from bytes_used and chain_size.
52
53 Creating a new key is easy with this method. Call this class method
54 with the bytes you want the key to recognize along with the size of
55 the chains you want the encryption/decryption processes to use."""
56 selection, blocks = list(set(bytes_used)), []
57 for _ in range(chain_size):
58 _CHAOS.shuffle(selection)
59 blocks.append(bytes(selection))
60 return cls(tuple(blocks))
61
62 def __init__(self, data):
63 """Initialize the Key instance's variables after testing the data.

Callers 10

recipe-578002.pyFile · 0.45
recipe-578001.pyFile · 0.45
recipe-578003.pyFile · 0.45
recipe-578069.pyFile · 0.45
recipe-578029.pyFile · 0.45
recipe-578016.pyFile · 0.45
auto_encrypt_bytesFunction · 0.45
auto_encrypt_strFunction · 0.45
recipe-578037.pyFile · 0.45
recipe-578048.pyFile · 0.45

Calls 7

listClass · 0.85
rangeFunction · 0.85
bytesFunction · 0.85
setFunction · 0.50
clsClass · 0.50
shuffleMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected