Note that there are some explanatory texts on larger screens.

plurals
  1. POObsfucate a 5 digit number
    text
    copied!<p>I wish to obfuscate a 5 digit number </p> <p>Properties of the obfuscated number that I care about:</p> <ul> <li>it's impossible (or as a fall back, extremely unlikely) to collide with other obfuscated numbers</li> <li>it's also a 5 digit number (no alpha characters please)</li> <li>it's not easily determinable by a regular human without computational assistance (e.g. it's not something obvious like "multiply by 2 and subtract 5" </li> <li>it's an algorithm ... as opposed to storing a look up table of all possible 5 digit numbers to their corresponding hash or some other "brute force" technique</li> </ul> <p>Properties of the obfuscated number that I don't care about:</p> <ul> <li>whether it's repeatable or not i.e. if "12345" always results in "73624", I okay</li> <li>whether it's cryptographically secure or not</li> </ul> <p>Thus far I haven't found anything that fits my requirements... but am hoping this is due to poor memory, incomplete education or dubious lifestyle choices rather than no "nice" solution being present.</p> <p>An example that can be easily translated into C# would be a bonus.</p> <p><strong>Update:</strong></p> <p>I'm investigating using the idea of doing a simple bit mapping for the moment.</p> <pre><code> static List&lt;int&gt; bitMapping = new List&lt;int&gt;() { 8, 6, 9, 3, 7, 5, ... etc... }; private static int Obfuscate(int number) { var bits = new bool[bitMapping.Count]; foreach (var ordinal in bitMapping) { var mask = (int)Math.Pow(2, ordinal); var bit = (mask &amp; number) == mask; var mappedOrdinal = bitMapping[ordinal]; bits[mappedOrdinal] = bit; } var obfuscatedNumber = 0; for (var ordinal = 0; ordinal &lt; bits.Length; ordinal++) { if (bits[ordinal]) { obfuscatedNumber += (int)Math.Pow(2, ordinal); } } return obfuscatedNumber; </code></pre> <p>It seems to meet most of my requirements thus far.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload