开发者

How can I obfuscate/de-obfuscate integer properties?

开发者 https://www.devze.com 2023-02-13 14:31 出处:网络
My users will in some cases be able to view a web version of a database table that stores data they\'ve entered.For various reasons I need to include all the stored data, including a number of integer

My users will in some cases be able to view a web version of a database table that stores data they've entered. For various reasons I need to include all the stored data, including a number of integer flags for each record that encapsulate adjacencies and so forth within the data (this is for speed and convenience at runtime). But rather than exposing them one-for-one in the webview, I'd like to have an obfuscated field that's just called "reserved" and contains a single unintelligible string representing those flags that I can easily encode and decode.

How can I do this e开发者_运维百科fficiently in C++/Objective C?

Thanks!


Is it necessary that this field is exposed to the user visually, or just that it’s losslessly captured in the HTML content of the webview? If possible, can you include the flags as a hidden input element with each row, i.e., <input type=“hidden” …?


Why not convert each of the fields to hex, and append them as a string and save that value?

As long as you always append the strings in the same order, breaking them back apart and converting them back to numbers should be trivial.


Use symmetric encryption (example) to encode and decode the values. Of course, only you should know of the key.
Alternatively, Assymetric RSA is more powerfull encryption but is less efficient and is more complex to use.

Note: i am curios about the "various reasons" that require this design...


Multiply your flag integer by 7, add 3, and convert to base-36. To check if the resulting string is modified, convert back to base-2, and check if the result modulo 7 is still 3. If so, divide by 7 to get the flags. note that this is subject to replay attacks - users can copy any valid string in.


Just calculate a CRC-32 (or similar) and append it to your value. That will tell you, with a very high probability, if your value has been corrupted.

0

精彩评论

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

关注公众号