f(a)=(a+k) mod n

Anybody know how to reverse it?

12 years ago*

Comment has been collapsed.

12 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 1 year ago.

12 years ago
Permalink

Comment has been collapsed.

uhm... well i didn't mention that... This formula is for moving alphabet about some value and the question is how to change it to come back to previous alphabet.

12 years ago
Permalink

Comment has been collapsed.

it a programming language ?

12 years ago
Permalink

Comment has been collapsed.

encryption model

12 years ago
Permalink

Comment has been collapsed.

i can't help u if i don't know what itz

12 years ago
Permalink

Comment has been collapsed.

Dafuq?

12 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 1 year ago.

12 years ago
Permalink

Comment has been collapsed.

Off hand, no. But it looks like you want the inverse of the modulo function. Maybe you can search out some information on that. If you can provide a bit more info on what's known and unknown in that formula, since there are three variables (a,k,n), that might help a little bit in figuring it out.

12 years ago
Permalink

Comment has been collapsed.

Hmm, if it's doing what I think it's doing (namely shifting an alphabet, a, by k and cycling around the alphabet size n) then the following should work to reverse it:

f(a) = ((a + n) - (k mod n)) mod n

Shifting forwards by the size of the alphabet to prevent values of a from going negative when shifted backwards (which would make using mod n to constrain it to the bounds of the alphabet size not work), then shifting it backwards by a value k constrained to the alphabet size (to again prevent it going negative), and then using mod n to constrain the end result to the alphabet size.

This may not be the most efficient or concise way of doing it, but if I've interpreted correctly, I think it should work for what you are doing.

12 years ago
Permalink

Comment has been collapsed.

Ill try it :)

12 years ago
Permalink

Comment has been collapsed.

Closed 12 years ago by MmikiM.