reverse of modulo (inverse?)
am 14.06.2011 15:39:00 von Deane.Rothenmaier
This is a multipart message in MIME format.
--===============1664711889==
Content-Type: multipart/alternative;
boundary="=_alternative 004AFBFC862578AF_="
This is a multipart message in MIME format.
--=_alternative 004AFBFC862578AF_=
Content-Type: text/plain; charset="US-ASCII"
Greetings.
I'm not having much luck finding this, and it's been a long time since
college math, so I thought I'd throw it at you folks and cross my
fingers...
I'm looking for an algorithm that reverses the modulo function. That is,
if x = y % 256, given x, what is y?
Broader picture is, I'm trying to back-figure a site number from an IP
address. E.g., given number x = 12345, the IP's middle octets ( x/256 and
x%256 respectively) come out to 48 and 57 . Is there an algorithm I can
put the numbers 48 and 57 into and have 12345 come out?
I looked in cpan and got lost, I've tried a few math sites, they all talk
about inverse of modulo, but I'm not sure that's what I'm asking for.
Here's hoping the collective wisdom will rescue me.
Thanks in advance!
Deane Rothenmaier
Programmer/Analyst -- IT-StdCfg
Walgreens Corp.
2 Overlook Point #N5102D
MS 6515
Lincolnshire, IL 60069
224-542-5150
If you have to write your ethical rules down, it's already too late. --
Tom Clancy
--=_alternative 004AFBFC862578AF_=
Content-Type: text/html; charset="US-ASCII"
Greetings.
I'm not having much luck finding this,
and it's been a long time since college math, so I thought I'd throw it
at you folks and cross my fingers...
I'm looking for an algorithm that reverses
the modulo function. That is, if x = y % 256, given x, what is y?
Broader picture is, I'm trying to back-figure
a site number from an IP address. E.g., given number x = 12345, the IP's
middle octets ( x/256 and x%256 respectively) come out to 48 and 57 . Is
there an algorithm I can put the numbers 48 and 57 into and have 12345
come out?
I looked in cpan and got lost, I've
tried a few math sites, they all talk about inverse of modulo, but I'm
not sure that's what I'm asking for. Here's hoping the collective wisdom
will rescue me.
Thanks in advance!
Deane Rothenmaier
Programmer/Analyst -- IT-StdCfg
Walgreens Corp.
2 Overlook Point #N5102D
MS 6515
Lincolnshire, IL 60069
224-542-5150
If you have to write your ethical rules down, it's already too late. --
Tom Clancy
--=_alternative 004AFBFC862578AF_=--
--===============1664711889==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1664711889==--
Re: reverse of modulo (inverse?)
am 14.06.2011 16:03:21 von Markus Hutmacher
This is a multi-part message in MIME format.
--===============1229858485==
Content-Type: multipart/alternative;
boundary="------------010107050507080901010406"
This is a multi-part message in MIME format.
--------------010107050507080901010406
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Am 06/14/2011 03:39 PM, schrieb Deane.Rothenmaier@walgreens.com:
>
> Greetings.
>
> I'm not having much luck finding this, and it's been a long time since
> college math, so I thought I'd throw it at you folks and cross my
> fingers...
>
> I'm looking for an algorithm that reverses the modulo function. That
> is, if x = y % 256, given x, what is y?
>
Hi,
there is no single result for your equation since there is an unlimited
number of solutions.
In fact any number
y=n*256 + x
will be a solution for you equation
Markus
--------------010107050507080901010406
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
http-equiv="Content-Type">
Am 06/14/2011 03:39 PM, schrieb
cite="mid:OF598501BF.DAB126EC-ON862578AF.0049BB8C-862578AF.0 04AFC01@walgreens.com"
type="cite">
Greetings.
I'm not having much luck finding
this,
and it's been a long time since college math, so I thought I'd
throw it
at you folks and cross my fingers...
I'm looking for an algorithm that
reverses
the modulo function. That is, if x = y % 256, given x, what is
y?
Hi,
there is no single result for your equation since there is an
unlimited number of solutions.
In fact any number
y=n*256 + x
will be a solution for you equation
Markus
--------------010107050507080901010406--
--===============1229858485==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1229858485==--
RE: reverse of modulo (inverse?)
am 14.06.2011 17:10:35 von Brian Raven
From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Deane.Rothenmaier@walgreens.com
Sent: 14 June 2011 14:39
To: activeperl@listserv.ActiveState.com
Subject: reverse of modulo (inverse?)
> Greetings.
>
> I'm not having much luck finding this, and it's been a long time since college math, so I thought I'd throw it > at you folks and cross my fingers...
>
> I'm looking for an algorithm that reverses the modulo function. That is, if x = y % 256, given x, what is y?
That's not possible, because you have discarded necessary information.
>
> Broader picture is, I'm trying to back-figure a site number from an IP address. E.g., given number x = 12345, > the IP's middle octets ( x/256 and x%256 respectively) come out to 48 and 57 . Is there an algorithm I can put > the numbers 48 and 57 into and have 12345 come out?
Well, that's a different question (assuming that I have understood the last paragraph). If you have both x/256 and x%256, and you know the modulus/divisor was 256, then you have enough to reconstruct the original. For example ...
use strict;
use warnings;
my $mod = 256;
for my $x (@ARGV) {
my $o1 = int($x / $mod);
my $o2 = $x % $mod;
my $orig_x = $o1 * $mod + $o2;
print "Starting with x=$x and mod=$mod, o1=$o1 o2=$o2, reconstructed x=$orig_x\n";
}
HTH
--
Brian Raven
Please consider the environment before printing this e-mail.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs