Skip to Content
物联网设备安全
book

物联网设备安全

by Nitesh Dhanjani
March 2017
Intermediate to advanced
262 pages
5h 26m
Chinese
China Machine Press
Content preview from 物联网设备安全
傻瓜盒子
——
攻击
智能
电视
129
5.2.1
理解
XOR
XOR
(异或,也可表示“
XOR
加密”)是一个布尔代数函数。其计算非常简单,如果
两个操作数有且只有一个是
true
,则计算结果是
true
。基于这一逻辑,如下表所示:
1 XOR 1 is 0
1 XOR 0 is 1
0 XOR 1 is 1
0 XOR 0 is 0
我们编写一个简单的
C
程序,将字串
cat
key
KEY
进行异或:
#include <stdio.h>
intmain()
{
char string[4]="cat";
char key[4]="KEY";
for(intx=0; x<3; x++)
{
string[x]=string[x]^key[x];
printf("%c",string[x]);
}
printf("\n");
return
}
注意在
C
语言里,
^
表示异或操作。现在编译程序:
$
gccxor.c -o xor
看看计算结果:
$
./xor
($-
cat
KEY
异或的结果是
($-
。这是因为程序将
c
K
异或,
a
E
异或,
t
Y
异或。我
们分析一下
c
K
异或。
c
ASCII
码值
99
,转换成二进制是
01100011
K
ASCII
码值是
75
,转换成二进制是
01001011
将这两个值异或:
01100011
(XOR) 01001011
--------
00101000
--------
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

数据科学之编程技术:使用R进行数据清理、分析与可视化

数据科学之编程技术:使用R进行数据清理、分析与可视化

迈克尔 弗里曼, 乔尔 罗斯
手把手教会你linux

手把手教会你linux

桑德.范.乌格特
C语言核心技术(原书第2版)

C语言核心技术(原书第2版)

Peter Prinz, Tony Crawford
机器学习设计模式

机器学习设计模式

Valliappa Lakshmanan, Sara Robinson, Michael Munn

Publisher Resources

ISBN: 9787111558668