Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encryption algorithm that output byte by byte based on password and offset

Is there a well-known (to be considered) algorithm that can encrypt/decrypt any arbitrary byte inside the file based on the password entered and the offset inside the file.

(Databyte, Offset, Password) => EncryptedByte
(EncryptedByte, Offset, Password) => DataByte

And is there some fundamental weakness in this approach or it's still theoretically possible to build it strong enough

Update: More datails: Any cryptographic algorithm has input and output. For many existing ones the input operates on large blocks. I want to operate on only one byte, but the system based on this can only can remap bytes and weak by default, but if we take the position in the file of this byte, we for example can take the bits of this position value to interpret them as some operation on some step (0: xor, 1: shitf) and create the encrypted byte with this. But it's too simple, I'm looking for something stronger.

like image 413
Maksee Avatar asked Apr 30 '26 05:04

Maksee


2 Answers

Maybe it's not very efficient but how about this:

for encryption use:

encryptedDataByte = Encrypt(offset,key) ^ dataByte

for decryption use:

dataByte = Encrypt(offset,key) ^ encryptedDataByte

Where Encrypt(offset,key) might be e.g. 3DES or AES (with padding the offset, if needed, and throwing away all but one result bytes)

like image 51
Curd Avatar answered May 03 '26 06:05

Curd


If you can live with block sizes of 16 byte, you can try the XTS-mode described in the wikipedia article about Disk encryption theory (the advantage being that some good cryptologists already looked at it).

If you really need byte-wise encryption, I doubt that there is an established solution. In the conference Crypto 2009 there was a talk about How to Encipher Messages on a Small Domain: Deterministic Encryption and the Thorp Shuffle. In your case the domain is a byte, and as this is a power of 2, a Thorp Shuffle corresponds to a maximally unbalanced Feistel network. Maybe one can build something using the position and the password as key, but I'd be surprised if a home-made solution will be secure.

like image 34
Whoever Avatar answered May 03 '26 07:05

Whoever



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!