|
@@ -0,0 +1,22 @@
|
|
|
+def xor_encrypt_decrypt(input_file, output_file, key):
|
|
|
+ with open(input_file, 'rb') as f:
|
|
|
+ data = f.read()
|
|
|
+
|
|
|
+ # 对文件内容执行异或操作
|
|
|
+ encrypted_data = bytes([byte ^ key for byte in data])
|
|
|
+
|
|
|
+ # 将处理后的内容写回文件或者保存到新文件中
|
|
|
+ with open(output_file, 'wb') as f:
|
|
|
+ f.write(encrypted_data)
|
|
|
+
|
|
|
+# 要处理的文件
|
|
|
+input_file = 'index2.html'
|
|
|
+# 输出文件
|
|
|
+output_file = 'index3.html'
|
|
|
+# 异或操作的密钥
|
|
|
+key = 0x12 # 例如,使用十六进制密钥
|
|
|
+
|
|
|
+# 执行异或操作
|
|
|
+xor_encrypt_decrypt(input_file, output_file, key)
|
|
|
+
|
|
|
+print("文件已加密/解密并保存到", output_file)
|