【问题标题】:Simple decryption in swift with key & dictionary?使用密钥和字典快速简单解密?
【发布时间】:2017-11-09 02:56:20
【问题描述】:

在较小的非问题上寻找正确方向的推动力,但更多的是好奇心驱动的搜索。

我正在尝试获取大量文本,这些文本已使用大写、小写和数字的普通日期密钥“加密”。 即。

Array('1'=>'h', '0'=>'L', '3'=>'H',....

在我的大脑中跌跌撞撞地试图思考是否有一种方法可以使用所提供的值/键来构建字典,我可以输入加密文本并参考字典以获取输出解密文本的答案吗?

【问题讨论】:

标签: swift encryption


【解决方案1】:

假设映射是 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()

【讨论】:

  • 怎么没有意义? let cypher = ["1": "h", "0": "L"] as [Character: Character]let cypher: [Character: Character] = ["1": "h", "0": "L"] 相同
  • 怎么不一样?诚实的问题伙伴。没必要对它刻薄:/
猜你喜欢
  • 2013-05-12
  • 1970-01-01
  • 2011-07-10
  • 2015-02-26
  • 2020-04-23
  • 1970-01-01
  • 2011-04-06
  • 2022-10-01
  • 2018-11-04
相关资源
最近更新 更多