Simple integer encryption

后端 未结 9 1497
南方客
南方客 2020-12-03 06:24

Is there a simple algorithm to encrypt integers? That is, a function E(i,k) that accepts an n-bit integer and a key (of any type) and produces another, unrelated n-bit integ

9条回答
  •  广开言路
    2020-12-03 06:47

    You could take an n-bit hash of your key (assuming it's private) and XOR that hash with the original integer to encrypt, and with the encrypted integer to decrypt.

    Probably not cryptographically solid, but depending on your requirements, may be sufficient.

提交回复
热议问题