Obfuscating an ID

前端 未结 11 531
逝去的感伤
逝去的感伤 2020-11-28 02:20

I\'m looking for a way to encrypt/obfuscate an integer ID into another integer. More precisely, I need a function int F(int x), so that

  • x<->F(x
11条回答
  •  情歌与酒
    2020-11-28 02:45

    Do anything with the bits of the ID that won't destroy them. For example:

    • rotate the value
    • use lookup to replace certain parts of the value
    • xor with some value
    • swap bits
    • swap bytes
    • mirror the whole value
    • mirror a part of the value
    • ... use your imagination

    For decryption, do all that in reverse order.

    Create a program that will 'encrypt' some interesting values for you and put them in a table you can examine. Have same program TEST your encryption/decryption routine WITH all set of values that you want to have in your system.

    Add stuff to the above list into the routines until your numbers will look properly mangled to you.

    For anything else, get a copy of The Book.

提交回复
热议问题