Purpose: I'd like to shuffle a file system's blocks without loosing space so I thought if I formatted the disk to have exactly 2^32=4bn sectors, then a secure cipher with 32 bit wide data blocks could map all sectors to new ones without wasting place, like a hash map would do due to its collision chances.

  • 2
    $\begingroup$ See crypto.stackexchange.com/questions/8771/… for the danger of a small block size $\endgroup$ Commented Dec 18, 2022 at 23:32
  • 3
    $\begingroup$ Format Preserving Encryption techniques let you use the same technique regardless of the number of blocks, by effectively constructing a keyed permutation of any integer interval. $\endgroup$
    – fgrieu
    Commented Dec 19, 2022 at 6:21
  • $\begingroup$ The actual purpose will be to shuffle several backups as a protection against ransomware, because if the virus can't match all the copies, I might be able to keep a system alive even during active infection. Yet what if s.b doesn't store >10⁶⁴ data - which is immense? The matching complexity increases exponentially with the number of copies, I assume. $\endgroup$
    – yacrc
    Commented Dec 19, 2022 at 7:12
  • 4
    $\begingroup$ @yacr: I don't see how encryption or shuffling blocks can be an effective protection against cryptoransomware. The problem is making the data out of reach of the malware (at least, out of of write reach), so that it can't rewrite it encrypted. $\endgroup$
    – fgrieu
    Commented Dec 19, 2022 at 7:28
  • 1
    $\begingroup$ The malware can simply damage your data no matter how it is encrypted. $\endgroup$
    – fraxinus
    Commented Dec 19, 2022 at 18:16

1 Answer 1


A block cipher with any given key is always a permutation. It will map all possible inputs to all possible outputs. If it didn't, and multiple inputs mapped to a single output, then it wouldn't be reversible.

Note that a 32-bit block size is not secure for encryption, as Eugene Styer pointed out in a comment. This is not likely to be an issue if you're only using it to "shuffle" $2^{32}$ sectors. For this, you could use Speck32/64, which is a block cipher with a 32-bit block and a 64-bit key. Again, it is not secure.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.