XOR在文件中逐行加密? [英] XOR Encryption line by line in a file?

查看:98
本文介绍了XOR在文件中逐行加密?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我将尽可能短,我理解xor加密,我想加密然后解密特定文件中的一些文本。



示例file.dat:<登记/>
<预郎= 文本>文本1
text2的
文字3
文本4
text5





我可以进行XOR加密,但我不能一行一行,特别是在阅读时解密...

有人可以给我一个?例如请

非常感谢您

解决方案
逐行 没有多大意义,当你谈论加密! - 甚至像XOR一样简单的系统 - 只是因为加密过程的结果可以是任何值 ,包括行尾代码



因此,如果你按行加密,那么你可能希望输出也是面向行的:这意味着你需要跳过原始数据中的行结束字符并按原样传输它们到输出文件。但是......如果您的加密数据生成行结束字符(尽可能非常容易)会怎么样?当您解密它时,您不会重新生成原始文件,因为您无法分辨加密输入中的哪些行是真实的而哪些不是。



始终将加密数据视为二进制 - 读取加密和读取以解密 - 从不作为文本,或者您会发现加密数据无法恢复的时间!


hello there! i will be as short as i can, i understant xor encryption, and i want to encrypt then decrypt some text in a specific file.

example file.dat:

text1
text2
text3
text4
text5



I am able to make XOR encryption, but i just can`t do it line by line, especially decrypting it while reading...
Can someone give me an example please?
Thank you very much!

解决方案

"Line by line" doesn't make much sense when you talk about encryption - even a system as simple as XOR - simply because the results of the encryption process can be any value including the end of line code.

So if you encrypt it by line, then presumably you want the output to also be line oriented: which means you need to skip the "line end characters" in the original data and transfer them "as is" to the output file. But...what if your encrypted data generates line end characters (as it can, very easily)? When you come to decrypt it, you don't regenerate the original file because you can't tell which lines in your encrypted input are "real" and which aren't.

Always treat encrypted data as binary - reading to encrypt and reading to decrypt - never as text, or you will find times when your encrypted data cannot be recovered!


这篇关于XOR在文件中逐行加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆