找回密码
 立即注册
加密EncryptionXOR运算符 | 系统编程 2021-06-11 517 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
C# XOR Encryption,C#异或加密字符串加密
C# 异或加密是加密字符串数据的一种原始方式。它永远不应该用于安全加密。然而,这是一种将有意义的文本隐藏起来的简单方法。
Xor 加密确实提供了数字密钥的使用,因此只能使用该密钥进行解密。
异或运算符
加密的基础是异或运算符。简而言之,xor 运算符以这种方式处理数字:
value1 xor value2 = value3
value3 xor value2 = value1
正如您可能知道的那样,异或加密将基于 value2 工作,在这种情况下它将是您的数字密钥。
异或加密
算法很简单,遍历字符串中的每个字符,将其转换为其整数 ASCII 值,将值与键进行异或,然后将新值转换回字符串。
要将字符转换为 int,请使用:
Convert.ToInt32([char here]);
要将 int 转换为 char,请使用:
char.ConvertFromUtf32([int here]);
由于 xor 运算符基本上是翻转值,因此您不需要单独的加密和解密函数。只需要一个函数来翻转字符值。 Xor 加密很简单,但是很好地介绍了字符串加密。


(C# XOR Encryption
String Encryption
C# xor encryption is a primitive way to encrypt string data. It should never be used for secure encryption. However it is a simple way to hide meaningful text from plain sight.
Xor encryption does offer the use of a number key, making decryption only possible with said key.
Xor Operator
The basis of the encryption is the xor operator. In a nutshell, the xor operator works this way with numbers:
value1 xor value2 = value3
value3 xor value2 = value1
As you can probably tell, xor encryption will work based on value2 which in this case will be your number key.
Xor Encryption
The algorithm is simple, go through each character in the string, convert it to its integer ASCII value, xor the value with the key, and convert the new value back into a string.
To convert a character to an int, use:
Convert.ToInt32([char here]);
To convert an int to a char, use:
char.ConvertFromUtf32([int here]);
Since the xor operator is basically flipping values, you do not need a separate encryption and decryption function. Only one funciton is needed to flip the character values. Xor encryption is simple, but is a good introduction to string encryption.)

1623387017982.rar


上一篇:WhiteMagic - Injected .NET Helper Library
下一篇:C# Self Hashing Application