本文整理汇总了Python中Level.Level.inputMsg方法的典型用法代码示例。如果您正苦于以下问题:Python Level.inputMsg方法的具体用法?Python Level.inputMsg怎么用?Python Level.inputMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level.Level
的用法示例。
在下文中一共展示了Level.inputMsg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: encryptFile
# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import inputMsg [as 别名]
def encryptFile():
CharIndexMap.rangeTypeisCharacterBased=False
start_time = time.time()
baseMachineCfg=EnigmaConfigGenerator(RandomGenerator(123)).createMachineConfig("MCb")
baseMachine=EnigmaDynamicFactory().createEnigmaMachineFromConfig(baseMachineCfg)
baseMachine.adjustMachineSettings()
levelMachine=EnigmaDynamicFactory().createEnigmaMachineFromModel("MCm")
levelMachine.adjustMachineSettings()
level=Level(baseMachine.getMachineSettings(),levelMachine.getMachineSettings())
elapsed_time = time.time() - start_time
print("2 MAchines were created in :"+str(elapsed_time))
start_time = time.time()
msg=FileReader().readSeqFromFile("tst.txt")
elapsed_time = time.time() - start_time
print("Parsed File to read Seq in : "+str(elapsed_time))
level.inputMsg=msg
start_time = time.time()
levelEncryptor=LevelEncryptor(baseMachine,levelMachine,level,RandomGenerator(123))
encLevel=levelEncryptor.encryptLevel()
elapsed_time = time.time() - start_time
print("Encrypted Seq in : "+str(elapsed_time))
FileReader().writeSeqTofile(encLevel.outputMsg,"tst.enc",True)
print("Encrypted File written")
encLevel.inputMsg=""
start_time = time.time()
levelDecryptor=LevelDecryptor(baseMachine,levelMachine,level)
levelDecryptor.level=encLevel
resultLevel=levelDecryptor.decryptLevel()
elapsed_time = time.time() - start_time
print("Decrypted Sequence in :"+str(elapsed_time))
FileReader().writeSeqTofile(resultLevel.inputMsg,"tst.dec",False)
print("Decrypted File written")
print("DONE !!")
示例2: encryptTextAsBin
# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import inputMsg [as 别名]
def encryptTextAsBin(writeToFile=False):
CharIndexMap.rangeTypeisCharacterBased=False
start_time = time.time()
seed=None
baseMachineModelName=EnigmaConfigGenerator(seed).createRandomModelName()
baseMachineCfg=EnigmaConfigGenerator(seed).createMachineConfig(baseMachineModelName)
if writeToFile:
Util.writeObjectToFileAsJson(baseMachineCfg,"./state/baseMcCfg.json")
baseMachine=EnigmaDynamicFactory(seed).createEnigmaMachineFromConfig(baseMachineCfg)
baseMcStg=MachineSettingManager(seed).generateRandomSettingsForMachine(baseMachine)
if writeToFile:
Util.writeObjectToFileAsJson(baseMcStg.getAsMap(),"./state/baseMcStg.json")
baseMachine.adjustMachineSettings(baseMcStg)
levelMachineModelName=EnigmaConfigGenerator(seed).createRandomModelName()
levelMcCfg=EnigmaConfigGenerator(seed).createMachineConfig(levelMachineModelName)
if writeToFile:
Util.writeObjectToFileAsJson(levelMcCfg,"./state/levelMcCfg.json")
levelMachine=EnigmaDynamicFactory(seed).createEnigmaMachineFromConfig(levelMcCfg)
levelMcStg=MachineSettingManager(seed).generateRandomSettingsForMachine(levelMachine)
if writeToFile:
Util.writeObjectToFileAsJson(levelMcStg.getAsMap(),"./state/levelMcStg.json")
levelMachine.adjustMachineSettings(levelMcStg)
level=Level(baseMcStg,levelMcStg,seed)
if writeToFile:
Util.writeObjectToFileAsJson(level.getAsMap(),"./state/level.json")
elapsed_time = time.time() - start_time
# print("2 MAchines were created in :"+str(elapsed_time))
msg="Hello Enigma !"
msgSeq=Util.encodeStringIntoByteList(msg)
level.inputMsg=msgSeq
start_time = time.time()
levelEncryptor=LevelEncryptor(baseMachine,levelMachine,level,seed)
encLevel=levelEncryptor.encryptLevel()
elapsed_time = time.time() - start_time
# print("Encrypted Seq in : "+str(elapsed_time))
print("ENC:")
print(Util.convertByteListIntoHexString(encLevel.outputMsg))
encLevel.inputMsg=""
start_time = time.time()
levelDecryptor=LevelDecryptor(baseMachine,levelMachine,level)
levelDecryptor.level=encLevel
resultLevel=levelDecryptor.decryptLevel()
elapsed_time = time.time() - start_time
# print("Decrypted Sequence in :"+str(elapsed_time))
# print("DEC:")
# print(resultLevel.inputMsg)
# print(Util.decodeByteListIntoString(resultLevel.inputMsg))
# print("DONE !!")
return resultLevel.inputMsg