{"id":81,"date":"2022-04-05T18:43:04","date_gmt":"2022-04-05T10:43:04","guid":{"rendered":"https:\/\/reverieland.cn\/?p=81"},"modified":"2022-04-05T18:49:25","modified_gmt":"2022-04-05T10:49:25","slug":"%e6%9c%89%e9%99%90%e5%9f%9f%e4%b8%8a%e8%bf%90%e7%ae%97%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/reverieland.cn\/index.php\/81\/","title":{"rendered":"\u6709\u9650\u57df\u4e0a\u8fd0\u7b97\u7684\u5b9e\u73b0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u5b9e\u9a8c\u539f\u7406\uff08\u7cbe\u7b80\uff09<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-1024x602.png\" alt=\"\" class=\"wp-image-82\" width=\"722\" height=\"424\" srcset=\"https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-1024x602.png 1024w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-300x176.png 300w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-768x451.png 768w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image.png 1254w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-center has-small-font-size\">\u56fe1\uff1a\u57fa\u672c\u539f\u7406<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"210\" src=\"https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-2-1024x210.png\" alt=\"\" class=\"wp-image-84\" srcset=\"https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-2-1024x210.png 1024w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-2-300x62.png 300w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-2-768x157.png 768w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-2.png 1151w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-small-font-size\">\u56fe2\uff1a\u6307\u6570\u5bf9\u6570\u8868<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u4ee3\u7801\u5b9e\u73b0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import time\n\ndef extract_info(str_polynimial):\n    length=len(str_polynimial)\n    add=1    \n    for i in range(length):\n        if i==0:  \n            j=0\n            while(j!=length and str_polynimial&#91;j]!='x'):\n                j+=1\n            if j+1==length or str_polynimial&#91;j+1]!='^':\n                index_list = &#91;0] *2\n                str_coefficient = \"\".join(&#91;str(item) for item in str_polynimial&#91;0:j]])\n                if str_coefficient==\"\":\n                    str_coefficient='1'\n                index=1\n                index_list&#91;index] = int(str_coefficient)\n            elif str_polynimial&#91;j+1]=='^':\n                k=j+2\n                while(k!=length and str_polynimial&#91;k]!='+' and str_polynimial&#91;k]!='-'):\n                    k+=1\n                str_index = \"\".join(&#91;str(item) for item in str_polynimial&#91;j+2:k]])\n                highest_index = int(str_index)  \n                index_list = &#91;0] * (highest_index + 1)\n                index = highest_index\n                if j == 0:  \n                    index_list&#91;index] = 1\n                else:\n                    str_coefficient = \"\".join(&#91;str(item) for item in str_polynimial&#91;0:j]])\n                    index_list&#91;index] = int(str_coefficient)\n\n        elif str_polynimial&#91;i]!='+' and str_polynimial&#91;i]!='-':\n            continue\n        else:\n            j = i\n            while (j!=length and str_polynimial&#91;j] != 'x'):\n                j += 1\n            str_coefficient = \"\".join(&#91;str(item) for item in str_polynimial&#91;i+1:j]])\n            if str_coefficient==\"\":     \n                str_coefficient='1'\n            if str_polynimial&#91;i]=='-':      \n                str_coefficient=\"-\"+str_coefficient\n            if j==length:      \n                str_index='0'\n            elif (j+1)==length or str_polynimial&#91;j+1]=='+'or str_polynimial&#91;j+1]=='-':        \n                str_index = '1'\n            else:\n                k=j+2\n                while(k!=length and str_polynimial&#91;k]!='+' and str_polynimial&#91;k]!='-'):\n                    k+=1\n                str_index=\"\".join(&#91;str(item) for item in str_polynimial&#91;j+2:k]])        \n            index_list&#91;int(str_index)]=int(str_coefficient)\n    index_list.reverse()\n    return index_list\n\ndef translation(list):\n    str_polynimial=\"\"\n    for i in range(len(list)):\n        if list&#91;i]==0:\n            continue\n        index=len(list)-i-1       \n        coefficient=list&#91;i]      \n        if index==0:\n            string=str(coefficient)\n        elif index==1:\n            if coefficient==1:\n                string = 'x'\n            else:\n                string=str(coefficient)+'x'\n        else:\n            if coefficient==1:\n                string = 'x' + '^' + str(index)\n            else:\n                string=str(coefficient)+'x'+'^'+str(index)\n        if i==0 or list&#91;i]&lt;0:\n            str_polynimial=str_polynimial+string\n        elif list&#91;i]&gt;0:\n            str_polynimial=str_polynimial+'+'+string\n\n    if str_polynimial==\"\":\n        str_polynimial=\"0\"\n    return str_polynimial\n\ndef Multiplication(list,a):\n    result=&#91;]\n    for i in range(len(list)):\n        result.append(list&#91;i]*a%2)\n    return result\n\ndef Multiplication2(list1,list2):\n    a=list1.copy()\n    b=list2.copy()\n    result=&#91;0]\n    for i in range(len(b)):\n        product=Multiplication(a,b&#91;i])\n        product.extend(&#91;0]*(len(b)-1-i))\n        result=Add(result,product)\n    return result\n\ndef Subtraction(list1,list2):\n    a=list1.copy()\n    b=list2.copy()\n    result=&#91;]\n    for i in range(len(a)):\n        result.append((a&#91;i]-b&#91;i])%2)\n    return result\n\ndef Subtraction2(list1,list2):\n    a=list1.copy()\n    b=list2.copy()\n    if len(a)&lt;len(b):\n        a.reverse()\n        a.extend(&#91;0]*(len(b)-len(a)))\n        a.reverse()\n    elif len(a)&gt;len(b):\n        b.reverse()\n        b.extend(&#91;0] * (len(a) - len(b)))\n        b.reverse()\n    result=Subtraction(a,b)\n    return result\n\ndef Add(list1,list2):\n    a=list1.copy()\n    b=list2.copy()\n    result=&#91;]\n    if len(a)&gt;len(b):\n        b.reverse()\n        b.extend(&#91;0]*(len(a)-len(b)))\n        b.reverse()\n        max=len(a)\n    else:\n        a.reverse()\n        a.extend(&#91;0]*(len(b)-len(a)))\n        a.reverse()\n        max=len(b)\n    for i in range(max):\n        result.append((a&#91;i]+b&#91;i])%2)\n    for j in range(len(result)):  \n        if result&#91;0] == 0:\n            result.remove(0)\n        else:\n            break\n    return result\n\ndef Division(list1,list2):\n    r=list1.copy()\n    b=list2.copy()\n    if len(r)&lt;len(b):\n        return &#91;0],list1\n    q=&#91;0]*(len(r)-len(b)+1)\n    for i in range(len(q)):\n        if len(r)&gt;=len(b):\n            index = len(r) - len(b) + 1  \n            q&#91;-index] = int(r&#91;0] \/ b&#91;0])\n            b_=b.copy()\n            b_.extend(&#91;0] * (len(r) - len(b)))\n            b_=Multiplication(b_,q&#91;i])\n            r = Subtraction(r ,b_)\n            for j in range(len(r)):     \n                if r&#91;0]==0:\n                    r.remove(0)\n                else:\n                    break\n        else:\n            break\n    return q,r\n\ndef G28_Multiplication(list1,list2,w):\n    a=list1.copy()\n    b=list2.copy()\n    Mul=Multiplication2(a,b)\n    _,r=Division(Mul,w)\n    return r\n\ndef Extend_Euclid(list1,list2,p):\n    f=list1.copy()\n    g=list2.copy()\n    u_2=&#91;1]\n    u_1=&#91;0]\n    v_2=&#91;0]\n    v_1=&#91;1]\n    while(g!=&#91;]):\n        q,r=Division(f,g)\n        u=Subtraction2(u_2,Multiplication2(q,u_1))\n        v=Subtraction2(v_2,Multiplication2(q,v_1))\n        f,g=g,r\n        u_2,u_1=u_1,u\n        v_2,v_1=v_1,v\n\n    d,u,v=f,u_2,v_2\n    return d,u,v\n\ndef tran_2_to_10(list):\n    result=0\n    for i in range(len(list)):\n        if list&#91;i]==1:\n            result+=2**(len(list)-1-i)\n    return result\n\ndef tran_10_to_2_list(number_code):\n    list=&#91;]\n    number=number_code\n    while(number!=0):\n        r=number%2\n        list.append(int(r))\n        number=(number-r)\/2\n    list.reverse()\n    return list\n\ndef test():\n    w = &#91;1, 0, 1, 1, 0, 0, 0, 1, 1]  \n    x = &#91;1, 0] \n    table = &#91;1]\n    table_F = &#91;0] * 256\n    for i in range(255):\n        if i == 254: \n            table.append(0)\n            table_F&#91;0] = 255\n            break\n        _, item = Division(x, w) \n        number = tran_2_to_10(item)\n        table_F&#91;number] = i + 1\n        table.append(number)\n        x.append(0)\n    print(\"GF(256)\u57df\u4e0b\uff0c\u5efa\u7acb\u6307\u6570\u5bf9\u6570\u8868\u5982\u4e0b\uff1a\")\n  \n\n    for i in range(len(table)):print(\"{:&lt;4}\".format(i), end=' ')\n    print(\"\\n\")\n    for j in table:print(\"{:&lt;4}\".format(j), end=' ')\n    print(\"\\n\")\n    for k in table_F:print(\"{:&lt;4}\".format(k), end=' ')\n    print(\"\\n*******************************************\")\n    a = input(\"\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u591a\u9879\u5f0f\uff1a\")\n    list_a = extract_info(a)\n    a_number = tran_2_to_10(list_a)\n    b = input(\"\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u591a\u9879\u5f0f\uff1a\")\n    list_b = extract_info(b)\n    b_number = tran_2_to_10(list_b)\n    num_product = table&#91;(table_F&#91;a_number] + table_F&#91;b_number]) % 255]  \n    list_product = tran_10_to_2_list(num_product)\n    str_product = translation(list_product)  \n    inverse_a = table&#91;255 - table_F&#91;a_number]]\n    list_inverse = tran_10_to_2_list(inverse_a)\n    str_inverse_a = translation(list_inverse)\n    print(\"GF\uff082^8\uff09\u4e0b\u591a\u9879\u5f0f\u79ef\u4e3a\uff1a\"+str_product)\n    print(\"GF\uff082^8\uff09\u4e0b\u591a\u9879\u5f0f\"+a+\"\u9006\u5143\u4e3a\uff1a\"+str_inverse_a)\n    return 0\n\nif __name__ == '__main__':\ntest()\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u751f\u6210\u6307\u6570\u5bf9\u6570\u8868\u793a\u4f8b<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"985\" height=\"458\" src=\"https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-3.png\" alt=\"\" class=\"wp-image-85\" srcset=\"https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-3.png 985w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-3-300x139.png 300w, https:\/\/reverieland.cn\/wp-content\/uploads\/2022\/04\/image-3-768x357.png 768w\" sizes=\"auto, (max-width: 985px) 100vw, 985px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-small-font-size\">\u56fe3\uff1a\u8282\u9009\u90e8\u5206\u6307\u6570\u5bf9\u6570\u8868<\/p>\n\n\n\n<p class=\"has-text-align-center\">---END---<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u8bb0\u5f55<\/p>\n","protected":false},"author":1,"featured_media":123,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[13],"tags":[14],"class_list":["post-81","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cybersecurity","tag-14"],"_links":{"self":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":4,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":126,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/posts\/81\/revisions\/126"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/media\/123"}],"wp:attachment":[{"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reverieland.cn\/index.php\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}