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

Function encrypt

recipes/Python/578062_Markov/recipe-578062.py:372–386  ·  view source on GitHub ↗
(bytes_obj, sudoku_key, boot_strap)

Source from the content-addressed store, hash-verified

370# boot_strap
371# - should be a proper "markov" bootstrap
372def encrypt(bytes_obj, sudoku_key, boot_strap):
373 _check_sudoku_key(sudoku_key)
374 _check_boot_strap(boot_strap, sudoku_key)
375 # make byte_map
376 array = sorted(sudoku_key[0])
377 byte_map = dict((byte, value) for value, byte in enumerate(array))
378 # create two more arguments for encode
379 grid = make_grid(sudoku_key)
380 index = list(map(byte_map.__getitem__, boot_strap))
381 # run the actual encoding algorithm and create reversed map
382 code, index = _encode(bytes_obj, byte_map, grid, index, len(sudoku_key[0]))
383 rev_map = dict(reversed(item) for item in byte_map.items())
384 # fix the boot_strap and return the results
385 boot_strap = bytes(rev_map[number] for number in index)
386 return code, boot_strap
387
388# string
389# - should be the string that you want encoded

Callers 1

encrypt_strFunction · 0.70

Calls 12

_check_sudoku_keyFunction · 0.85
_check_boot_strapFunction · 0.85
make_gridFunction · 0.85
listClass · 0.85
mapFunction · 0.85
bytesFunction · 0.85
_encodeFunction · 0.70
sortedFunction · 0.50
dictFunction · 0.50
enumerateFunction · 0.50
reversedFunction · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected