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

Function encrypt_str

recipes/Python/578062_Markov/recipe-578062.py:394–401  ·  view source on GitHub ↗
(string, word_size, plain_chars='')

Source from the content-addressed store, hash-verified

392# plain_chars
393# - characters that you do not want to encrypt
394def encrypt_str(string, word_size, plain_chars=''):
395 byte_obj = string.encode(CODEC, 'ignore')
396 encode_on = set(byte_obj).difference(set(plain_chars.encode()))
397 sudoku_key = make_sudoku_key(encode_on, word_size)
398 boot_strap = make_boot_strap(sudoku_key)
399 cyphertext = encrypt(byte_obj, sudoku_key, boot_strap)[0]
400 # return encrypted string, key, and original bootstrap
401 return cyphertext.decode(CODEC, 'ignore'), sudoku_key, boot_strap
402
403def grid_size(string, word_size, plain_chars):
404 encode_on = set(string.encode()).difference(set(plain_chars.encode()))

Callers 1

reevaluateMethod · 0.70

Calls 7

make_sudoku_keyFunction · 0.85
make_boot_strapFunction · 0.85
encryptFunction · 0.70
setFunction · 0.50
encodeMethod · 0.45
differenceMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected