{"id":23657,"date":"2023-05-05T06:09:58","date_gmt":"2023-05-05T06:09:58","guid":{"rendered":"https:\/\/www.booksofall.com\/cn\/?post_type=product&#038;p=23657"},"modified":"2023-05-05T06:09:59","modified_gmt":"2023-05-05T06:09:59","slug":"crypto-101","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/cn\/crypto-101\/","title":{"rendered":"Crypto 101"},"content":{"rendered":"<div id=\"reading-mode-page-div-17\" class=\"reading-mode-page-div\">\n<h2>5 &#8211; Exclusive or<\/h2>\n<h4>5.1 Description<\/h4>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Exclusive_or\">Exclusive or<\/a>, often called \u201cXOR\u201d, is a Boolean binary operator that is true when either the first input or the second input, but not both, are true.<\/p>\n<p>Another way to think of XOR is as something called a \u201cprogrammable inverter\u201d: one input bit decides whether to invert the other input bit, or to just pass it through unchanged. \u201cInverting\u201d bits is colloquially called \u201cflipping\u201d bits, a term we\u02bcll use often throughout the book.<\/p>\n<p id=\"FSbCizO\"><img loading=\"lazy\" decoding=\"async\" width=\"197\" height=\"107\" class=\"alignnone size-full wp-image-23661 \" src=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/img_64549b19467b3.png\" alt=\"\" \/><\/p>\n<p>In mathematics and cryptography papers, exclusive or is generally represented by a cross in a circle:\u00a0<i>\u2295<\/i>. We\u02bcll use the same notation in this book:<\/p>\n<p id=\"VynkUxi\"><img loading=\"lazy\" decoding=\"async\" width=\"199\" height=\"76\" class=\"alignnone size-full wp-image-23663 \" src=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/img_64549b2d859b7.png\" alt=\"\" \/><\/p>\n<\/div>\n<div id=\"reading-mode-page-div-18\" class=\"reading-mode-page-div\">\n<p>The inputs and output here are named as if we\u02bcre using XOR as an encryption operation. On the left, we have the plaintext bit\u00a0<i>Pi<\/i>. The\u00a0<i>i\u00a0<\/i>is just an index, since we\u02bcll usually deal with more than one such bit. On top, we have the key bit\u00a0<i>ki<\/i>, that decides whether or not to invert\u00a0<i>Pi<\/i>. On the right, we have the ciphertext bit,\u00a0<i>Ci<\/i>, which is the result of the XOR operation.<\/p>\n<h4>5.2 A few properties of XOR<\/h4>\n<p>Since we\u02bcll be dealing with XOR extensively during this book, we\u02bcll take a closer look at some of its properties. If you\u02bcre already familiar with how XOR works, feel free to skip this section.<\/p>\n<p>We saw that the output of XOR is 1 when one input or the other (but not both) is 1:<\/p>\n<p id=\"jDhDnpd\"><img loading=\"lazy\" decoding=\"async\" width=\"194\" height=\"52\" class=\"alignnone size-full wp-image-23664 \" src=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/img_64549b598f356.png\" alt=\"\" \/><\/p>\n<p>There are a few useful arithmetic tricks we can derive from that.<\/p>\n<ol>\n<li>You can apply XOR in any order: <i>a\u2295<\/i>(<i>b\u2295c<\/i>) = (<i>a\u2295b<\/i>)<i>\u2295c<\/i><\/li>\n<li>You can flip the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Operand\">operands<\/a> around: <i>a\u2295 b\u00a0<\/i>=\u00a0<i>b\u2295 a<\/i><\/li>\n<li>Any bit XOR itself is 0: <i>a \u2295 a\u00a0<\/i>= 0. If\u00a0<i>a\u00a0<\/i>is 0, then it s\u0313 0<i>\u2295\u00a0<\/i>0 = 0; if\u00a0<i>a\u00a0<\/i>is 1, then it s\u0313 1<i>\u2295\u00a0<\/i>1 = 0.<\/li>\n<li>Any bit XOR 0 is that bit again: <i>a\u2295\u00a0<\/i>0 =\u00a0<i>a<\/i>. If\u00a0<i>a\u00a0<\/i>is 0, then it s\u0313 0<i>\u2295\u00a0<\/i>0 = 0; if\u00a0<i>a\u00a0<\/i>is 1, then it s\u0313 1<i>\u2295\u00a0<\/i>0 = 1.<\/li>\n<\/ol>\n<\/div>\n<div id=\"readering-mode-page-19\"><\/div>\n<div id=\"reading-mode-page-div-19\" class=\"reading-mode-page-div\">\n<p>These rules also imply\u00a0<i>a\u2295 b\u2295 a\u00a0<\/i>=\u00a0<i>b<\/i>:<\/p>\n<p id=\"TbXLiIs\"><img loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"73\" class=\"alignnone size-full wp-image-23665 \" src=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/img_64549b7fbe8ca.png\" alt=\"\" \/><\/p>\n<p>We\u02bcll use this property often when using XOR for <a href=\"https:\/\/cloud.google.com\/learn\/what-is-encryption\">encryption<\/a>; you can think of that first XOR with\u00a0<i>a\u00a0<\/i>as encrypting, and the second one as decrypting.<\/p>\n<div id=\"reading-mode-page-div-19\" class=\"reading-mode-page-div\">\n<h4>5.3 Bitwise XOR<\/h4>\n<p>XOR, as we\u02bcve just defined it, operates only on single bits or Boolean values. Since we usually deal with values comprised of many bits, most programming languages provide a \u201c<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Bitwise_XOR\">bitwise XOR<\/a>\u201d operator: an operator that performs XOR on the respective bits in a value.<\/p>\n<p>Python, for example, provides the ^ (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Caret\">caret<\/a>) operator that performs bitwise XOR on integers. It does this by first expressing those two integers in <a href=\"https:\/\/www.computerhope.com\/jargon\/b\/binary.htm\">binary<\/a>, and then performing XOR on their respective bits. Hence the name, <i>bitwise\u00a0<\/i>XOR.<\/p>\n<p id=\"xGALYwA\"><img loading=\"lazy\" decoding=\"async\" width=\"377\" height=\"179\" class=\"alignnone size-full wp-image-23666 \" src=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/img_64549b9380e10.png\" alt=\"\" \/><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/crypto101-1cg1mv40ny?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":23667,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!"},"product_brand":[],"product_cat":[383],"product_tag":[],"class_list":{"0":"post-23657","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-security-privacy","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Crypto 101 - BooksOfAll Simplified Chinese<\/title>\n<meta name=\"description\" content=\"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/cn\/crypto-101\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Crypto 101 - BooksOfAll Simplified Chinese\" \/>\n<meta property=\"og:description\" content=\"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/cn\/crypto-101\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll Simplified Chinese\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-05T06:09:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/\",\"url\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/\",\"name\":\"Crypto 101 - BooksOfAll Simplified Chinese\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/cn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg\",\"datePublished\":\"2023-05-05T06:09:58+00:00\",\"dateModified\":\"2023-05-05T06:09:59+00:00\",\"description\":\"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/cn\/crypto-101\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"Crypto 101\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/cn\/crypto-101\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/cn\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Crypto 101\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/cn\/#website\",\"url\":\"https:\/\/www.booksofall.com\/cn\/\",\"name\":\"BooksOfAll Simplified Chinese\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/cn\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/cn\/#organization\",\"name\":\"BooksOfAll Simplified Chinese\",\"url\":\"https:\/\/www.booksofall.com\/cn\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.booksofall.com\/cn\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll Simplified Chinese\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/cn\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Crypto 101 - BooksOfAll Simplified Chinese","description":"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.booksofall.com\/cn\/crypto-101\/","og_locale":"zh_CN","og_type":"article","og_title":"Crypto 101 - BooksOfAll Simplified Chinese","og_description":"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!","og_url":"https:\/\/www.booksofall.com\/cn\/crypto-101\/","og_site_name":"BooksOfAll Simplified Chinese","article_modified_time":"2023-05-05T06:09:59+00:00","og_image":[{"url":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg","twitter_misc":{"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/cn\/crypto-101\/","url":"https:\/\/www.booksofall.com\/cn\/crypto-101\/","name":"Crypto 101 - BooksOfAll Simplified Chinese","isPartOf":{"@id":"https:\/\/www.booksofall.com\/cn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/cn\/crypto-101\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/cn\/crypto-101\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg","datePublished":"2023-05-05T06:09:58+00:00","dateModified":"2023-05-05T06:09:59+00:00","description":"Unlock the secrets of cryptosystems with this book and gain a deeper understanding beyond just the basics of cryptography. Read the book here!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/cn\/crypto-101\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/cn\/crypto-101\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.booksofall.com\/cn\/crypto-101\/#primaryimage","url":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg","contentUrl":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2023\/05\/Crypto-101.jpg","width":"827","height":"1169","caption":"Crypto 101"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/cn\/crypto-101\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/cn\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/cn\/categories\/"},{"@type":"ListItem","position":3,"name":"Crypto 101"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/cn\/#website","url":"https:\/\/www.booksofall.com\/cn\/","name":"BooksOfAll Simplified Chinese","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/cn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/cn\/#organization","name":"BooksOfAll Simplified Chinese","url":"https:\/\/www.booksofall.com\/cn\/","logo":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.booksofall.com\/cn\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/cn\/wp-content\/uploads\/sites\/2\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll Simplified Chinese"},"image":{"@id":"https:\/\/www.booksofall.com\/cn\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/product\/23657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/media\/23667"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/media?parent=23657"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/product_brand?post=23657"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/product_cat?post=23657"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/cn\/wp-json\/wp\/v2\/product_tag?post=23657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}