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

Function decrypt

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

Source from the content-addressed store, hash-verified

442# boot_strap
443# - should be a proper "markov" bootstrap
444def decrypt(bytes_obj, sudoku_key, boot_strap):
445 _check_sudoku_key(sudoku_key)
446 _check_boot_strap(boot_strap, sudoku_key)
447 # make byte_map
448 array = sorted(sudoku_key[0])
449 byte_map = dict((byte, value) for value, byte in enumerate(array))
450 # create two more arguments for decode
451 grid = make_grid(sudoku_key)
452 grid = make_decode_grid(grid, len(sudoku_key[0]))
453 index = list(map(byte_map.__getitem__, boot_strap))
454 # run the actual decoding algorithm and create reversed map
455 code, index = _decode(bytes_obj, byte_map, grid, index, len(sudoku_key[0]))
456 rev_map = dict(reversed(item) for item in byte_map.items())
457 # fix the boot_strap and return the results
458 boot_strap = bytes(rev_map[number] for number in index)
459 return code, boot_strap
460
461# string
462# - should be the string that you want decoded

Callers 1

decrypt_strFunction · 0.70

Calls 13

_check_sudoku_keyFunction · 0.85
_check_boot_strapFunction · 0.85
make_gridFunction · 0.85
make_decode_gridFunction · 0.85
listClass · 0.85
mapFunction · 0.85
bytesFunction · 0.85
_decodeFunction · 0.70
sortedFunction · 0.50
dictFunction · 0.50
enumerateFunction · 0.50
reversedFunction · 0.50

Tested by

no test coverage detected