尝试加密和解密 code-beginner

Trying to encrypt and decrypt code-beginner

所以这是一个位操作练习,我对它们如何将字母转换为数字感到困惑,我认为这些不是二进制的,所以我不知道它们是什么意思。 任何人都可以建议一种方法吗?

Here's two examples of encryption: "cats" and "kittens".

Pairs: "ca ts" "ki tt en s_" (_ represents a space) into ints: 25441 29811 27497 29812 25966 29472 XOR with 31337: 6408 3610 4352 3613 7943 2377

'c'的Ascii值是99,'a'的Ascii值是97。把它们当作base 256的数字。那么"ac"就是99*256 + 97 = 25441。注意在C中,char是数字类型,所以'c' 99等

每对字母的十进制五元组就是ASCII字符的十六进制值串联的十进制表示,例如:

"ca" = 0x63 0x61 = 0x6361 = 25441

异或密钥的情况相同

31337 = 0x7A69

确实

0x6361 ^ 0x7A69 = 0x1908 = 6408 in decimal