0

There is a form with 2 fields: X and Y. X is known, Y is generated later via ajax based on X. After the submit I would like to check if Y was generated by me or not.

I'm looking for a function (and its inverse) that is more complicated to figure out than the example below:

x = 7 (random number)
y = f(x)
x = g(y)

example:
f = +2
g = -2

x = 7
y = 9
x = 7
Todd
  • 30,472
  • 11
  • 81
  • 89

1 Answers1

1

Why not use f(x) again and check its output against the posted value of y? That way you are even able to make irreversible valies for y (like md5 or sha)?

  • Could you provide an example, please? –  Jan 09 '14 at 13:29
  • I think this way I have to store the generated number. –  Jan 09 '14 at 13:30
  • No, as the output of f(x) will be the same result. If it has to be random you would need to store your result of f(x) on the server, as reversing the value of y would not result in x as it is random anyway – Stijn van Grinsven Jan 09 '14 at 14:24
  • I was looking for this http://stackoverflow.com/a/9262137/669677, but your solution is more logical in my case. Thank you! –  Jan 09 '14 at 14:32