Classical-Cipher

幫助破譯凱撒密碼

  • August 10, 2014

我必須找到以下凱撒密碼的移位值和消息。 OC_VAWDGPM_VHWTVX_VXJOCVZ_GDX_MWO_VWIZVYGWIZ_NODI_

我已經嘗試過了,移位值為 21,我得到以下結果。 TH_AFBILUR_AMBYAC_ACOTHAE_LIC_RBT_ABNEADLBNE_STIN_

這對任何人來說都是正確的解密消息嗎?

我應該如何確定正確答案?我想我做錯了什麼

以下是所有可能的解密:

  1. NB_UZVCFOL_UGVSUW_UWINBUY_FCW_LVN_UVHYUXFVHY_MNCH_
  2. MA_TYUBENK_TFURTV_TVHMATX_EBV_KUM_TUGXTWEUGX_LMBG_
  3. LZ_SXTADMJ_SETQSU_SUGLZSW_DAU_JTL_STFWSVDTFW_KLAF_
  4. KY_RWSZCLI_RDSPRT_RTFKYRV_CZT_ISK_RSEVRUCSEV_JKZE_
  5. JX_QVRYBKH_QCROQS_QSEJXQU_BYS_HRJ_QRDUQTBRDU_IJYD_
  6. IW_PUQXAJG_PBQNPR_PRDIWPT_AXR_GQI_PQCTPSAQCT_HIXC_
  7. HV_OTPWZIF_OAPMOQ_OQCHVOS_ZWQ_FPH_OPSORZPBS_GHWB_
  8. GU_NSOVYHE_NZOLNP_NPBGUNR_YVP_EOG_NOARNQYOAR_FGVA_
  9. FT_MRNUXGD_MYNKMO_MOAFTMQ_XUO_DNF_MNZQMPXNZQ_EFUZ_
  10. ES_LQMTWFC_LXMJLN_LNZESLP_WTN_CME_LMYPLOWMYP_DETY_
  11. DR_KPLSVEB_KWLIKM_KMYDRKO_VSM_BLD_KLXOKNVLXO_CDSX_
  12. CQ_JOKRUDA_JVKHJL_JLXCQJN_URL_AKC_JKWNJMUKWN_BCRW_
  13. BP_INJQTCZ_IUJGIK_IKWBPIM_TQK_ZJB_IJVMILTJVM_ABQV_
  14. AO_HMIPSBY_HTIFHJ_HJVAOHL_SPJ_YIA_HIULHKSIUL_ZAPU_
  15. ZN_GLHORAX_GSHEGI_GIUZNGK_ROI_XHZ_GHTKGJRHTK_YZOT_
  16. YM_FKGNQZW_FRGDFH_FHTYMFJ_QNH_WGY_FGSJFIQGSJ_XYNS_
  17. XL_EJFMPYV_EQFCEG_EGSXLEI_PMG_VFX_EFRIEHPFRI_WXMR_
  18. WK_DIELOXU_DPEBDF_DFRWKDH_OLF_UEW_DEQHDGOEQH_VWLQ_
  19. VJ_CHDKNWT_CODACE_CEQVJCG_NKE_TDV_CDPGCFNDPG_UVKP_
  20. UI_BGCJMVS_BNCZBD_BDPUIBF_MJD_SCU_BCOFBEMCOF_TUJO_ **- TH_AFBILUR_AMBYAC_ACOTHAE_LIC_RBT_ABNEADLBNE_STIN_**22. SG_ZEAHKTQ_ZLAXZB_ZBNSGZD_KHB_QAS_ZAMDZCKAMD_RSHM_
  21. RF_YDZGJSP_YKZWYA_YAMRFYC_JGA_PZR_YZLCYBJZLC_QRGL_
  22. QE_XCYFIRO_XJYVXZ_XZLQEXB_IFZ_OYQ_XYKBXAIYKB_PQFK_
  23. PD_WBXEHQN_WIXUWY_WYKPDWA_HEY_NXP_WXJAWZHXJA_OPEJ_
  24. OC_VAWDGPM_VHWTVX_VXJOCVZ_GDX_MWO_VWIZVYGWIZ_NODI_

您實際上是在做正確的事情,但是您沒有將“”作為字元集的一部分。假設字母表由27個字母(AZ 和“”)組成,並使用附加的 JavaScript 腳本(您可以簡單地將其粘貼到控制台中),返回一個確實有意義的句子:

THE_FAILURE_MAY_BE_BOTH_DELIBERATE_AND_CLANDESTINE

var ciphertext = "OC_VAWDGPM_VHWTVX_VXJOCVZ_GDX_MWO_VWIZVYGWIZ_NODI_";

var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_"];

var rotation = 1;

var cleartext = "";

while (rotation < 27) {
for (var i=0,l=ciphertext.length;i<l;i++) {

 var character = ciphertext[i];

 var index = 0;

 // get the number in the alphabet
 for (var j=0;j<27;j++) {
   if (alphabet[j] === character) {
     index = j;
     break;
   }
 }

 // rotate

 cleartext += alphabet[(index + rotation) % 27];
}

console.log(cleartext);
rotation++;
cleartext = "";
}

編輯:關於上面的腳本,我想添加一件事。我們正在做 $ index + rotation \bmod 27 $ 在這裡,因為我們正在嘗試一種可能性。從嚴格意義上講,這是密文的另一種加密,只是一次旋轉當然必須產生明文。如果 $ rotation $ 已知並且您想使用此確切值解密密碼,您當然必須計算 $ (index - rotation + 27) \bmod 27 $ .

引用自:https://crypto.stackexchange.com/questions/18562