{"id":9390,"date":"2023-03-16T20:11:59","date_gmt":"2023-03-17T04:11:59","guid":{"rendered":"https:\/\/www.shop2world.com\/blog\/?p=9390"},"modified":"2023-03-16T20:57:03","modified_gmt":"2023-03-17T04:57:03","slug":"php-%eb%b8%94%eb%a1%9d-%ec%b2%b4%ec%9d%b8-%eb%b8%94%eb%a1%9d%ec%b2%b4%ec%9d%b8-%eb%b3%b4%ec%95%88-51-%ea%b3%b5%ea%b2%a9-%ec%8b%9c%eb%ae%ac%eb%a0%88%ec%9d%b4%ec%85%98","status":"publish","type":"post","link":"https:\/\/www.shop2world.com\/blog\/archives\/9390","title":{"rendered":"[PHP \ube14\ub85d \uccb4\uc778] \ube14\ub85d\uccb4\uc778 \ubcf4\uc548 : 51% \uacf5\uaca9 \uc2dc\ubbac\ub808\uc774\uc158"},"content":{"rendered":"\n<p>*\ube14\ub85d\uccb4\uc778\uc740 \ubcf4\uc548\uc131\uc774 \ub192\uc740 \ubd84\uc0b0 \uc2dc\uc2a4\ud15c\uc73c\ub85c\uc368, \ube14\ub85d\uccb4\uc778\uc758 \ubb34\uacb0\uc131\uc744 \ud574\ud0b9\ud558\uc5ec \uc704\uc870\ud558\ub824\ub294 \uc2dc\ub3c4\ub294 \ube14\ub85d\uccb4\uc778 \uae30\uc220\uc758 \ubcf4\uc548\uc131\uacfc \uc548\uc815\uc131\uc744 \uce68\ud574\ud558\ub294 \uac83\uc73c\ub85c \ubd88\ubc95\uc774\uba70, \ubc95\uc801 \ucc98\ubc8c\uc744 \ubc1b\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br>\uc774 \uae00\uc740 \uc774\ub7f0 \ube14\ub85d\uccb4\uc778\uc758 \ubcf4\uc548 \uc704\ud5d8\uc5d0 \ub300\ud574 \ucde8\uc57d\uc810\uc744 \ud30c\uc545, \ubc29\uc5b4\ub97c \uc704\ud55c \uc5f0\uad6c \ubaa9\uc801\uc785\ub2c8\ub2e4. <\/p>\n\n\n\n<p>51% \uacf5\uaca9\uc740 \ube14\ub85d\uccb4\uc778\uc5d0\uc11c \uac00\uc7a5 \ud070 \uc704\ud611 \uc911 \ud558\ub098\uc785\ub2c8\ub2e4. \uc774 \uacf5\uaca9\uc744 \uc2dc\ub3c4\ud558\ub824\uba74 \ub300\ub2e4\uc218\uc758 \ucef4\ud4e8\ud305 \ud30c\uc6cc\uac00 \ud544\uc694\ud569\ub2c8\ub2e4. \uc774 \uc608\uc2dc\uc5d0\uc11c\ub294 \uac00\uc0c1\uc73c\ub85c \ube14\ub85d\uccb4\uc778\uc5d0\uc11c\uc758 51% \uacf5\uaca9\uc744 \uc2dc\ubbac\ub808\uc774\uc158\ud574\ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<br><br><\/p>\n\n\n<pre><!--?php\n\/\/ \uccb4\uc778\uc744 \ub098\ud0c0\ub0b4\ub294 \ubc30\uc5f4\n$blockchain = array();\n\n\/\/ \uccb4\uc778\uc5d0 \ube14\ub85d \ucd94\uac00 \ud568\uc218\nfunction addBlock($data) {\n    global $blockchain;\n    $prevBlock = $blockchain[count($blockchain)-1];\n    $newBlock = array(\n        \"index\" =--> count($blockchain),\n        \"timestamp\" =&gt; time(),\n        \"data\" =&gt; $data,\n        \"prevHash\" =&gt; $prevBlock[\"hash\"]\n    );\n    $newBlock[\"hash\"] = hash(\"sha256\", json_encode($newBlock));\n    array_push($blockchain, $newBlock);\n}\n\n\/\/ 1. \uc815\uc0c1\uc801\uc778 \ub178\ub4dc \uc791\ub3d9 \uc2dc\ub098\ub9ac\uc624\n\/\/ \ube14\ub85d \ucd94\uac00\naddBlock(\"transaction1\");\naddBlock(\"transaction2\");\naddBlock(\"transaction3\");\n\n\/\/ \ube14\ub85d\uccb4\uc778 \ucd9c\ub825\necho \"\uc815\uc0c1\uc801\uc778 \ub178\ub4dc \uc791\ub3d9 \uc2dc\ub098\ub9ac\uc624:\\n\";\necho json_encode($blockchain) . \"\\n\";\n\n\/\/ 2. 51% \uacf5\uaca9 \uc2dc\ub098\ub9ac\uc624\n\/\/ \uccb4\uc778 \ucd08\uae30\ud654\n$blockchain = array();\n\/\/ \uccab \ube14\ub85d \ucd94\uac00\n$genesisBlock = array(\n    \"index\" =&gt; 0,\n    \"timestamp\" =&gt; time(),\n    \"data\" =&gt; \"genesis block\",\n    \"prevHash\" =&gt; \"\"\n);\n$genesisBlock[\"hash\"] = hash(\"sha256\", json_encode($genesisBlock));\narray_push($blockchain, $genesisBlock);\n\n\/\/ \ub300\ub2e4\uc218\uc758 \ucef4\ud4e8\ud305 \ud30c\uc6cc\ub97c \ud1b5\ud55c 51% \uacf5\uaca9\n\/\/ \uccb4\uc778 \uae38\uc774\uac00 4 \uc774\uc0c1\uc774 \ub420 \ub54c\uae4c\uc9c0 \ube14\ub85d \ucd94\uac00\nwhile (count($blockchain) &lt; 4) {\n    \/\/ \uacf5\uaca9\uc790\ub294 \uc774\uc804 \uccb4\uc778\uc758 \ub9c8\uc9c0\ub9c9 \ube14\ub85d\uc744 \uac00\uc838\uc640\uc11c \ud574\uc2dc \uac12\uc744 \ubcc0\uacbd\ud558\uc5ec \uc0c8\ub85c\uc6b4 \ube14\ub85d\uc744 \ucd94\uac00\n    $prevBlock = $blockchain[count($blockchain)-1];\n    $newBlock = array(\n        \"index\" =&gt; count($blockchain),\n        \"timestamp\" =&gt; time(),\n        \"data\" =&gt; \"malicious transaction\",\n        \"prevHash\" =&gt; $prevBlock[\"hash\"]\n    );\n    $newBlock[\"hash\"] = \"fake hash\";\n    array_push($blockchain, $newBlock);\n}\n\n\/\/ \ube14\ub85d\uccb4\uc778 \ucd9c\ub825\necho \"51% \uacf5\uaca9 \uc2dc\ub098\ub9ac\uc624:\\n\";\necho json_encode($blockchain) . \"\\n\";\n?&gt;\n<\/pre>\n<p>\uc704 \ucf54\ub4dc\uc5d0\uc11c\ub294 \uccb4\uc778\uc744 \ubc30\uc5f4\ub85c \ud45c\ud604\ud558\uace0, \ube14\ub85d \ucd94\uac00 \uc2dc \uc774\uc804 \ube14\ub85d\uc758 \ud574\uc2dc \uac12\uc744 \uc774\uc6a9\ud558\uc5ec \uc0c8\ub85c\uc6b4 \ube14\ub85d\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4. 51% \uacf5\uaca9 \uc2dc\ub098\ub9ac\uc624\uc5d0\uc11c\ub294 \ucc98\uc74c\uc5d0 \uccb4\uc778\uc744 \ucd08\uae30\ud654\ud558\uace0, \uccab \ubc88\uc9f8 \ube14\ub85d\ub9cc \uc0dd\uc131\ud569\ub2c8\ub2e4. \uadf8\ub9ac\uace0 \ub300\ub2e4\uc218\uc758 \ucef4\ud4e8\ud305 \ud30c\uc6cc\ub97c \ud1b5\ud574 \uc0c8\ub85c\uc6b4 \ube14\ub85d\uc744 \ucd94\uac00\ud558\uba74\uc11c \uc774\uc804 \uccb4\uc778\uc758 \ub9c8\uc9c0\ub9c9 \ube14\ub85d\uc758 \ud574\uc2dc \uac12\uc744 \ubcc0\uacbd\ud569\ub2c8\ub2e4. \uc704 \ucf54\ub4dc\uc5d0\uc11c\ub294 \uccb4\uc778\uc744 \ubc30\uc5f4\ub85c \ud45c\ud604\ud558\uace0, \ube14\ub85d \ucd94\uac00 \uc2dc \uc774\uc804 \ube14\ub85d\uc758 \ud574\uc2dc \uac12\uc744 \uc774\uc6a9\ud558\uc5ec \uc0c8\ub85c\uc6b4 \ube14\ub85d\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<p><strong>51% \uacf5\uaca9 \ubc29\uc5b4 \uae30\uc220<\/strong><\/p>\n<div class=\"flex-1 overflow-hidden\">\n<div class=\"react-scroll-to-bottom--css-gtwbl-79elbk h-full dark:bg-gray-800\">\n<div class=\"react-scroll-to-bottom--css-gtwbl-1n7m0yu\">\n<div class=\"flex flex-col items-center text-sm dark:bg-gray-800\">\n<div class=\"group w-full text-gray-800 dark:text-gray-100 border-b border-black\/10 dark:border-gray-900\/50 bg-gray-50 dark:bg-[#444654]\">\n<div class=\"text-base gap-4 md:gap-6 md:max-w-2xl lg:max-w-2xl xl:max-w-3xl p-4 md:py-6 flex lg:px-0 m-auto\">\n<div class=\"relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]\">\n<div class=\"flex flex-grow flex-col gap-3\">\n<div class=\"min-h-[20px] flex flex-col items-start gap-4 whitespace-pre-wrap\">\n<div class=\"markdown prose w-full break-words dark:prose-invert dark\">\n<p>51% \uacf5\uaca9\uc744 \ubc29\uc5b4\ud558\uae30 \uc704\ud55c \uc5ec\ub7ec \uac00\uc9c0 \ubc29\ubc95\uc774 \uc788\uc2b5\ub2c8\ub2e4. \uba87 \uac00\uc9c0 \ubc29\ubc95\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<ol>\n<li>\n<p>\ud569\uc758 \uc54c\uace0\ub9ac\uc998 \ubcc0\uacbd: \ube14\ub85d\uccb4\uc778\uc758 \ud569\uc758 \uc54c\uace0\ub9ac\uc998\uc744 \ubcc0\uacbd\ud558\uba74 51% \uacf5\uaca9\uc758 \uc704\ud611\uc744 \uc904\uc77c \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, PoW(Proof of Work)\uc5d0\uc11c PoS(Proof of Stake)\ub85c \uc804\ud658\ud558\ub294 \uac83\uc774 \uadf8 \uc608\uc785\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>\ubd84\uae30 \uc81c\ud55c: \ube14\ub85d\uccb4\uc778\uc5d0\uc11c \ubd84\uae30\ub97c \uc81c\ud55c\ud558\ub294 \uac83\uc740 51% \uacf5\uaca9\uc758 \uc704\ud611\uc744 \uc904\uc77c \uc218 \uc788\ub294 \ub610 \ub2e4\ub978 \ubc29\ubc95\uc785\ub2c8\ub2e4. \uc774\ub97c \uc704\ud574, \uc0c8 \ube14\ub85d\uc744 \uc0dd\uc131\ud558\uae30 \uc804\uc5d0 \uc774\uc804 \ube14\ub85d\ub4e4\uc744 \ud655\uc778\ud558\uace0 \uc77c\uc815 \uae30\uac04 \ub3d9\uc548 \ubd84\uae30\uac00 \uc5c6\ub294 \uac83\uc744 \ud655\uc778\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>\ubd84\uc0b0 \ub124\ud2b8\uc6cc\ud06c \uad6c\ucd95: \ubd84\uc0b0 \ub124\ud2b8\uc6cc\ud06c\ub97c \uad6c\ucd95\ud568\uc73c\ub85c\uc368 51% \uacf5\uaca9\uc744 \ubc29\uc5b4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ubd84\uc0b0 \ub124\ud2b8\uc6cc\ud06c\ub97c \uad6c\ucd95\ud558\uba74 \ub300\ub2e4\uc218\uc758 \ucef4\ud4e8\ud305 \ud30c\uc6cc\ub97c \ubaa8\uc73c\ub294 \uac83\uc774 \uc5b4\ub824\uc6cc\uc9c0\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>\ube14\ub85d \uc0dd\uc131 \uc18d\ub3c4 \uc81c\ud55c: \ube14\ub85d \uc0dd\uc131 \uc18d\ub3c4\ub97c \uc81c\ud55c\ud558\uc5ec 51% \uacf5\uaca9\uc744 \ubc29\uc5b4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub97c \uc704\ud574, \ube14\ub85d \uc0dd\uc131\uc5d0 \uc77c\uc815 \uc2dc\uac04\uc744 \uac78\ub9ac\ub3c4\ub85d \ud558\ub294 \uac83\uc774 \uadf8 \uc608\uc785\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>\ube14\ub85d\uccb4\uc778 \uac10\uc2dc: \ube14\ub85d\uccb4\uc778 \uac10\uc2dc\ub97c \ud1b5\ud574 51% \uacf5\uaca9\uc744 \ubc29\uc5b4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub97c \uc704\ud574, \ube14\ub85d\uccb4\uc778 \ub124\ud2b8\uc6cc\ud06c\ub97c \ubaa8\ub2c8\ud130\ub9c1\ud558\uc5ec \uacf5\uaca9\uc744 \uac10\uc9c0\ud558\uace0 \ub300\ucc98\ud558\ub294 \uac83\uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/p>\n<\/li>\n<li>\n<p>\ud569\uc758 \uc54c\uace0\ub9ac\uc998 \uacb0\ud569: \ub2e4\uc591\ud55c \ud569\uc758 \uc54c\uace0\ub9ac\uc998\uc744 \uacb0\ud569\ud568\uc73c\ub85c\uc368 51% \uacf5\uaca9\uc744 \ubc29\uc5b4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, PoW\uc640 PoS\ub97c \uacb0\ud569\ud558\ub294 \uac83\uc774 \uadf8 \uc608\uc785\ub2c8\ub2e4.<\/p>\n<\/li>\n<\/ol>\n<p>\uc774\ub7ec\ud55c \ubc29\ubc95 \uc678\uc5d0\ub3c4 \ub2e4\uc591\ud55c \ubc29\ubc95\uc774 \uc788\uc73c\uba70, \uac01 \ube14\ub85d\uccb4\uc778\uc740 \uc790\uccb4\uc801\uc73c\ub85c \uc801\uc808\ud55c \ubc29\uc5b4 \uc804\ub7b5\uc744 \ucc44\ud0dd\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"flex justify-between\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center mt-2 gap-3 md:gap-4 lg:gap-1 lg:absolute lg:top-0 lg:translate-x-full lg:right-0 lg:mt-0 lg:pl-2 visible\">\u00a0<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full h-32 md:h-48 flex-shrink-0\">\u00a0<\/div>\n<\/div>\n<p>\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"absolute bottom-0 left-0 w-full border-t md:border-t-0 dark:border-white\/20 md:border-transparent md:dark:border-transparent md:bg-vert-light-gradient bg-white dark:bg-gray-800 md:!bg-transparent dark:md:bg-vert-dark-gradient pt-2\"><form class=\"stretch mx-2 flex flex-row gap-3 last:mb-2 md:mx-4 md:last:mb-6 lg:mx-auto lg:max-w-3xl\">\n<div class=\"relative flex h-full flex-1 md:flex-col\">\n<div class=\"flex ml-1 md:w-full md:m-auto md:mb-2 gap-0 md:gap-2 justify-center\">\u00a0<\/div>\n<\/div>\n<\/form><\/div>","protected":false},"excerpt":{"rendered":"<p>*\ube14\ub85d\uccb4\uc778\uc740 \ubcf4\uc548\uc131\uc774 \ub192\uc740 \ubd84\uc0b0 \uc2dc\uc2a4\ud15c\uc73c\ub85c\uc368, \ube14\ub85d\uccb4\uc778\uc758 \ubb34\uacb0\uc131\uc744 \ud574\ud0b9\ud558\uc5ec \uc704\uc870\ud558\ub824\ub294 \uc2dc\ub3c4\ub294 \ube14\ub85d\uccb4\uc778 \uae30\uc220\uc758 \ubcf4\uc548\uc131\uacfc \uc548\uc815\uc131\uc744 \uce68\ud574\ud558\ub294 \uac83\uc73c\ub85c \ubd88\ubc95\uc774\uba70, \ubc95\uc801 \ucc98\ubc8c\uc744 \ubc1b\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\uc774 \uae00\uc740 \uc774\ub7f0 \ube14\ub85d\uccb4\uc778\uc758 \ubcf4\uc548 \uc704\ud5d8\uc5d0 \ub300\ud574 \ucde8\uc57d\uc810\uc744 \ud30c\uc545, \ubc29\uc5b4\ub97c \uc704\ud55c \uc5f0\uad6c \ubaa9\uc801\uc785\ub2c8\ub2e4. 51% \uacf5\uaca9\uc740 \ube14\ub85d\uccb4\uc778\uc5d0\uc11c \uac00\uc7a5 \ud070 \uc704\ud611 \uc911 \ud558\ub098\uc785\ub2c8\ub2e4. \uc774 \uacf5\uaca9\uc744 \uc2dc\ub3c4\ud558\ub824\uba74 \ub300\ub2e4\uc218\uc758 \ucef4\ud4e8\ud305 \ud30c\uc6cc\uac00 \ud544\uc694\ud569\ub2c8\ub2e4. \uc774 \uc608\uc2dc\uc5d0\uc11c\ub294 \uac00\uc0c1\uc73c\ub85c \ube14\ub85d\uccb4\uc778\uc5d0\uc11c\uc758 51% \uacf5\uaca9\uc744 \uc2dc\ubbac\ub808\uc774\uc158\ud574\ubcf4\uaca0\uc2b5\ub2c8\ub2e4. count($blockchain), &#8220;timestamp&#8221; =&gt; time(), &#8220;data&#8221; =&gt; $data, &#8220;prevHash&#8221; =&gt; $prevBlock[&#8220;hash&#8221;] ); $newBlock[&#8220;hash&#8221;] = hash(&#8220;sha256&#8221;, json_encode($newBlock)); array_push($blockchain, $newBlock); } \/\/ &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[716],"tags":[725],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts\/9390"}],"collection":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/comments?post=9390"}],"version-history":[{"count":4,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts\/9390\/revisions"}],"predecessor-version":[{"id":9396,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/posts\/9390\/revisions\/9396"}],"wp:attachment":[{"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/media?parent=9390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/categories?post=9390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shop2world.com\/blog\/wp-json\/wp\/v2\/tags?post=9390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}