MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / getBlocksFromText

Function getBlocksFromText

ciphers/rsa_cipher.py:40–49  ·  view source on GitHub ↗
(message, blockSize=DEFAULT_BLOCK_SIZE)

Source from the content-addressed store, hash-verified

38
39
40def getBlocksFromText(message, blockSize=DEFAULT_BLOCK_SIZE):
41 messageBytes = message.encode('ascii')
42
43 blockInts = []
44 for blockStart in range(0, len(messageBytes), blockSize):
45 blockInt = 0
46 for i in range(blockStart, min(blockStart + blockSize, len(messageBytes))):
47 blockInt += messageBytes[i] * (BYTE_SIZE ** (i % blockSize))
48 blockInts.append(blockInt)
49 return blockInts
50
51
52def getTextFromBlocks(blockInts, messageLength, blockSize=DEFAULT_BLOCK_SIZE):

Callers 1

encryptMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected