{"id":8148,"date":"2024-06-21T15:01:03","date_gmt":"2024-06-21T07:01:03","guid":{"rendered":""},"modified":"2024-06-21T15:01:03","modified_gmt":"2024-06-21T07:01:03","slug":"\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u4ee3\u7801_\u7ecf\u5178\u5bc6\u7801\u8868","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8148.html","title":{"rendered":"\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u4ee3\u7801_\u7ecf\u5178\u5bc6\u7801\u8868"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801<\/h2>\n

\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u539f\u7406<\/h3>\n

Vigenenre\u5bc6\u7801\u662f\u6700\u8457\u540d\u7684\u591a\u8868\u4ee3\u6362\u5bc6\u7801\uff0c\u662f16\u4e16\u7eaa\u6cd5\u56fd\u8457\u540d\u5bc6\u7801\u5b66\u5bb6Vigenenre\u53d1\u660e\u7684\u3002Vigenenre\u5bc6\u7801\u4f7f\u7528\u4e00\u4e2a\u8bcd\u7ec4\u4f5c\u4e3a\u5bc6\u94a5\uff0c\u5bc6\u94a5\u4e2d\u6bcf\u4e00\u4e2a\u5b57\u6bcd\u7528\u6765\u786e\u5b9a\u4e00\u4e2a\u4ee3\u6362\u8868\uff0c\u6bcf\u4e00\u4e2a\u5bc6\u94a5\u5b57\u6bcd\u88ab\u7528\u6765\u52a0\u5bc6\u4e00\u4e2a\u660e\u6587\u5b57\u6bcd\uff0c\u7b2c\u4e00\u4e2a\u5bc6\u94a5\u5b57\u6bcd\u52a0\u5bc6\u7b2c\u4e00\u4e2a\u660e\u6587\u5b57\u6bcd\uff0c\u7b2c\u4e8c\u4e2a\u5bc6\u94a5\u5b57\u6bcd\u52a0\u5bc6\u7b2c\u4e8c\u4e2a\u660e\u6587\u5b57\u6bcd\uff0c\u7b49\u6240\u6709\u5bc6\u94a5\u5b57\u6bcd\u4f7f\u7528\u5b8c\u540e\uff0c\u5bc6\u94a5\u518d\u6b21\u5faa\u73af\u4f7f\u7528\uff0c\u4e8e\u662f\u52a0\u89e3\u5bc6\u524d\u9700\u5148\u5c06\u660e\u5bc6\u6587\u6309\u7167\u5bc6\u94a5\u957f\u5ea6\u8fdb\u884c\u5206\u7ec4\u3002\u5bc6\u7801\u7b97\u6cd5\u53ef\u8868\u793a\u5982\u4e0b\uff1a
\u8bbe\u5bc6\u94a5K=(k1,k2,\u2026,kd)\uff0c\u660e\u6587M=(m1,m2,\u2026,mn)\uff0c\u5bc6\u6587C=(c1,c2,\u2026,cn)\uff1b
\u52a0\u5bc6\u53d8\u6362\u4e3a\uff1aci=Eki(mi)=mi+ki(mod 26)
\u89e3\u5bc6\u53d8\u6362\u4e3a\uff1ami=Dki(ci)=ci-ki(mod 26)
\u5176\u4e2dk=(k1,k2,\u2026,km)\u662f\u4e00\u4e2a\u957f\u4e3am\u7684\u5bc6\u94a5\u5b57\uff0c\u5bc6\u94a5\u7a7a\u95f4\u7684\u5927\u5c0f\u4e3a26m\uff0c\u6240\u4ee5\u5bf9\u4e00\u4e2a\u76f8\u5bf9\u5c0f\u7684m\uff0c\u7a77\u4e3e\u5bc6\u94a5\u4e5f\u9700\u8981\u5f88\u957f\u7684\u65f6\u95f4\u3002\u5982m=7\uff0c\u5219\u5bc6\u94a5\u7a7a\u95f4\u5927\u5c0f\u8d85\u8fc78\u00d7109\uff0c\u6240\u4ee5\u624b\u5de5\u641c\u7d22\u975e\u5e38\u56f0\u96be\u3002\u5f53\u660e\u6587\u7684\u957f\u5ea6\u8d85\u8fc7m\u65f6\uff0c\u53ef\u5c06\u660e\u6587\u4e32\u6309\u957f\u5ea6m\u5206\u5c40\uff0c\u7136\u540e\u5bf9\u6bcf\u4e00\u7ec4\u4f7f\u7528\u5bc6\u94a5k\u52a0\u5bc6\u3002
Vigenere\u5bc6\u7801\u7b97\u6cd5\u4e3b\u8981\u6709c\u3001m\u3001k\u4e09\u4e2a\u4e2a\u53c2\u6570\u3002c\u4e3a\u5bc6\u6587\uff0cm\u662f\u660e\u6587\uff0ck\u4e3a\u5bc6\u94a5\u3002<\/p>\n

C++\u4ee3\u7801<\/h3>\n
#include<<\/span>iostream><\/span> using namespace std;<\/span> int main<\/span>(<\/span>)<\/span> { \n   <\/span> int flag,<\/span>i,<\/span>len,<\/span>lenk;<\/span> char m[<\/span>50<\/span>]<\/span>,<\/span>c[<\/span>50<\/span>]<\/span>,<\/span>key[<\/span>50<\/span>]<\/span>;<\/span> cout<<<\/span>\"\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u7b97\u6cd5\uff01\"<\/span><<<\/span>endl;<\/span> cout<<<\/span>\"\u8bf7\u8f93\u51650\u62161:\"<\/span><<<\/span>endl;<\/span> cout<<<\/span>\"0:\u52a0\u5bc6\"<\/span><<<\/span>endl;<\/span> cout<<<\/span>\"1:\u89e3\u5bc6\"<\/span><<<\/span>endl;<\/span> cout<<<\/span>\"\u8bf7\u9009\u62e9\uff1a\"<\/span>;<\/span> cin>><\/span>flag;<\/span> switch<\/span>(<\/span>flag)<\/span> { \n   <\/span> case<\/span> 0<\/span>:<\/span> cout<<<\/span>\"\u8bf7\u8f93\u5165\u660e\u6587:\"<\/span>;<\/span> cin>><\/span>m;<\/span> cout<<<\/span>\"\u8bf7\u8f93\u5165\u79d8\u94a5:\"<\/span>;<\/span> cin>><\/span>key;<\/span> len=<\/span>strlen<\/span>(<\/span>m)<\/span>;<\/span> lenk=<\/span>strlen<\/span>(<\/span>key)<\/span>;<\/span> cout<<<\/span>\"\u52a0\u5bc6\u540e\u7684\u5bc6\u6587\u4e3a\uff1a\"<\/span>;<\/span> for<\/span>(<\/span>i=<\/span>0<\/span>;<\/span>i<<\/span>len;<\/span>i++<\/span>)<\/span> { \n   <\/span> flag=<\/span>(<\/span>key[<\/span>i%<\/span>lenk]<\/span>-<\/span>'a'<\/span>)<\/span>%<\/span>26<\/span>;<\/span> c[<\/span>i]<\/span>=<\/span>(<\/span>m[<\/span>i]<\/span>-<\/span>'a'<\/span>+<\/span>flag)<\/span>%<\/span>26<\/span>+<\/span>'a'<\/span>;<\/span> cout<<<\/span>c[<\/span>i]<\/span>;<\/span> }<\/span> cout<<<\/span>endl;<\/span> break<\/span>;<\/span> case<\/span> 1<\/span>:<\/span> cout<<<\/span>\"\u8bf7\u8f93\u5165\u5bc6\u6587:\"<\/span>;<\/span> cin>><\/span>c;<\/span> cout<<<\/span>\"\u8bf7\u8f93\u5165\u79d8\u94a5:\"<\/span>;<\/span> cin>><\/span>key;<\/span> len=<\/span>strlen<\/span>(<\/span>c)<\/span>;<\/span> lenk=<\/span>strlen<\/span>(<\/span>key)<\/span>;<\/span> cout<<<\/span>\"\u89e3\u5bc6\u540e\u7684\u660e\u6587\u4e3a\uff1a\"<\/span>;<\/span> for<\/span>(<\/span>i=<\/span>0<\/span>;<\/span>i<<\/span>len;<\/span>i++<\/span>)<\/span> { \n   <\/span> flag=<\/span>(<\/span>key[<\/span>i%<\/span>lenk]<\/span>-<\/span>'a'<\/span>)<\/span>%<\/span>26<\/span>;<\/span> if<\/span>(<\/span>c[<\/span>i]<\/span>>=<\/span>key[<\/span>i%<\/span>lenk]<\/span>)<\/span> m[<\/span>i]<\/span>=<\/span>(<\/span>c[<\/span>i]<\/span>-<\/span>'a'<\/span>-<\/span>flag)<\/span>%<\/span>26<\/span>+<\/span>'a'<\/span>;<\/span> else<\/span> m[<\/span>i]<\/span>=<\/span>(<\/span>c[<\/span>i]<\/span>+<\/span>26<\/span>-<\/span>'a'<\/span>-<\/span>flag)<\/span>+<\/span>'a'<\/span>;<\/span> cout<<<\/span>m[<\/span>i]<\/span>;<\/span> }<\/span> cout<<<\/span>endl;<\/span> break<\/span>;<\/span> default<\/span>:<\/span> cout<<<\/span>\"\u9009\u62e9\u9519\u8bef\uff01\u8bf7\u9009\u62e90\u62161\uff01\"<\/span><<<\/span>endl;<\/span> }<\/span> return<\/span> 0<\/span>;<\/span> }<\/span> <\/code><\/pre>\n

\u52a0\u5bc6\u89e3\u5bc6\u7ed3\u679c<\/h3>\n

\u52a0\u5bc6\uff1a
\"\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u4ee3\u7801_\u7ecf\u5178\u5bc6\u7801\u8868
\u89e3\u5bc6\uff1a
\"\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u4ee3\u7801_\u7ecf\u5178\u5bc6\u7801\u8868<\/p>\n","protected":false},"excerpt":{"rendered":"\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u4ee3\u7801_\u7ecf\u5178\u5bc6\u7801\u8868\u53e4\u5178\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u7ef4\u5409\u5c3c\u4e9a\u5bc6\u7801\u539f\u7406Vigenenre\u5bc6\u7801\u662f\u6700\u8457\u540d\u7684\u591a\u8868\u4ee3\u6362\u5bc6\u7801\uff0c\u662f16\u4e16\u7eaa...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8148"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8148"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8148\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}