Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用密钥和字典在swift中进行简单解密?_Swift_Encryption - Fatal编程技术网

使用密钥和字典在swift中进行简单解密?

使用密钥和字典在swift中进行简单解密?,swift,encryption,Swift,Encryption,在一个小问题上寻找一个正确的方向,但更多的好奇心驱动的搜索 我试图获取大量文本,这些文本使用大写、小写和数字以普通密钥加密。 即 我在脑子里跌跌撞撞地想,是否有办法用ben提供的值/密钥建立一个字典?我可以输入加密文本并参考字典以获得输出解密文本的答案吗?假设映射为1:1,即1个字符映射为1个字符,即没有数字大于9。这应该起作用: let cypher = ["1": "h", "0": "L"] as [Character: Character]

在一个小问题上寻找一个正确的方向,但更多的好奇心驱动的搜索

我试图获取大量文本,这些文本使用大写、小写和数字以普通密钥加密。 即


我在脑子里跌跌撞撞地想,是否有办法用ben提供的值/密钥建立一个字典?我可以输入加密文本并参考字典以获得输出解密文本的答案吗?

假设映射为1:1,即1个字符映射为1个字符,即没有数字大于9。这应该起作用:

let cypher = ["1": "h",
              "0": "L"] as [Character: Character]
             //Add more here as needed.

let yourText = "014"

let decypheredText = yourText.map { char in
    return cypher[char] ?? "?" //Untranslatable things mpa to ?
}.joined()

你试过什么?你能发布你为解决这个问题而写的代码吗?这怎么毫无意义?让cypher=[1:h,0:L]作为[Character:Character]与让cypher:[Character:Character]=[1:h,0:L]是一样的,这怎么不一样呢?诚实的问题伙伴。不必对此大惊小怪:/
let cypher = ["1": "h",
              "0": "L"] as [Character: Character]
             //Add more here as needed.

let yourText = "014"

let decypheredText = yourText.map { char in
    return cypher[char] ?? "?" //Untranslatable things mpa to ?
}.joined()