开发者

Java crypt file using XOR

I'm trying to find a very efficient way to encrypt files. One way that I think is very efficient ( CPU-wise, not security-level wise ), is doing a XOR during writing and another xor at reading ( with a 4-bytes key for example ).

The way I want to do it is by creat开发者_如何学编程ing my own Decorator of InputStream and OutputStream. Does anyone know a better method/most efficient than that ?


The way I want to do it is by creating my own Decorator of InputStream and OutputStream. Does anyone know a better method/most efficient than that

Create subclasses of FilterInputStream and FilterOutputStream.


An XOR cypher is an example of a Stream Cypher. An obsolete, but easy to program, example is RC4. For more modern, but not so easy, examples have a look at the cyphers in the eSTREAM portfolio: HC-128, Rabbit, Salsa 20/12 and SOSEMANUK.

Alternatively, a Block Cypher, such as AES, used in CTR Mode is equivalent to a Stream Cypher.

If you do not need very strong security then try RC4. Otherwise, AES in CTR Mode is probably the easiest, given its universal availability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜