Classical-Cipher
幫助破譯凱撒密碼
我必須找到以下凱撒密碼的移位值和消息。 OC_VAWDGPM_VHWTVX_VXJOCVZ_GDX_MWO_VWIZVYGWIZ_NODI_
我已經嘗試過了,移位值為 21,我得到以下結果。 TH_AFBILUR_AMBYAC_ACOTHAE_LIC_RBT_ABNEADLBNE_STIN_
這對任何人來說都是正確的解密消息嗎?
我應該如何確定正確答案?我想我做錯了什麼
以下是所有可能的解密:
- NB_UZVCFOL_UGVSUW_UWINBUY_FCW_LVN_UVHYUXFVHY_MNCH_
- MA_TYUBENK_TFURTV_TVHMATX_EBV_KUM_TUGXTWEUGX_LMBG_
- LZ_SXTADMJ_SETQSU_SUGLZSW_DAU_JTL_STFWSVDTFW_KLAF_
- KY_RWSZCLI_RDSPRT_RTFKYRV_CZT_ISK_RSEVRUCSEV_JKZE_
- JX_QVRYBKH_QCROQS_QSEJXQU_BYS_HRJ_QRDUQTBRDU_IJYD_
- IW_PUQXAJG_PBQNPR_PRDIWPT_AXR_GQI_PQCTPSAQCT_HIXC_
- HV_OTPWZIF_OAPMOQ_OQCHVOS_ZWQ_FPH_OPSORZPBS_GHWB_
- GU_NSOVYHE_NZOLNP_NPBGUNR_YVP_EOG_NOARNQYOAR_FGVA_
- FT_MRNUXGD_MYNKMO_MOAFTMQ_XUO_DNF_MNZQMPXNZQ_EFUZ_
- ES_LQMTWFC_LXMJLN_LNZESLP_WTN_CME_LMYPLOWMYP_DETY_
- DR_KPLSVEB_KWLIKM_KMYDRKO_VSM_BLD_KLXOKNVLXO_CDSX_
- CQ_JOKRUDA_JVKHJL_JLXCQJN_URL_AKC_JKWNJMUKWN_BCRW_
- BP_INJQTCZ_IUJGIK_IKWBPIM_TQK_ZJB_IJVMILTJVM_ABQV_
- AO_HMIPSBY_HTIFHJ_HJVAOHL_SPJ_YIA_HIULHKSIUL_ZAPU_
- ZN_GLHORAX_GSHEGI_GIUZNGK_ROI_XHZ_GHTKGJRHTK_YZOT_
- YM_FKGNQZW_FRGDFH_FHTYMFJ_QNH_WGY_FGSJFIQGSJ_XYNS_
- XL_EJFMPYV_EQFCEG_EGSXLEI_PMG_VFX_EFRIEHPFRI_WXMR_
- WK_DIELOXU_DPEBDF_DFRWKDH_OLF_UEW_DEQHDGOEQH_VWLQ_
- VJ_CHDKNWT_CODACE_CEQVJCG_NKE_TDV_CDPGCFNDPG_UVKP_
- 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_
- RF_YDZGJSP_YKZWYA_YAMRFYC_JGA_PZR_YZLCYBJZLC_QRGL_
- QE_XCYFIRO_XJYVXZ_XZLQEXB_IFZ_OYQ_XYKBXAIYKB_PQFK_
- PD_WBXEHQN_WIXUWY_WYKPDWA_HEY_NXP_WXJAWZHXJA_OPEJ_
- 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 $ .