当前位置: 首页>>代码示例>>Python>>正文


Python Level.getAsMap方法代码示例

本文整理汇总了Python中Level.Level.getAsMap方法的典型用法代码示例。如果您正苦于以下问题:Python Level.getAsMap方法的具体用法?Python Level.getAsMap怎么用?Python Level.getAsMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Level.Level的用法示例。


在下文中一共展示了Level.getAsMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: encryptTextAsBin

# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import getAsMap [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
开发者ID:mrfawy,项目名称:ModernEnigma,代码行数:68,代码来源:Main.py


注:本文中的Level.Level.getAsMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。