TJakobsen wrote:
> hehe sorry but i dont really understand how to use this in my program
> as im only a high school student (last year though). We don't have
> advanced mathematics yet and we haven't really worked with any of the
> mathematics related to RSA such as modulo etc.
>
> could someone be so kind as to go through this Extended Euclidian
> algorithn using the numbers i've used in my program please?
> so we can calculate d.
Perhaps you can translate this Java into your C++.
long inverse(long ee, long mm) {
if (ee<=1) {
if (ee==1) {
return 1;
}
throw new IllegalArgumentException(
"ee must be >=1, not "+ee);
}
// If we can find ss and tt such that
// ss*ee+tt*mm=1
// then ss would be the inverse of ee modulo mm. We
// could return ss=(1-tt*mm)/ee or, even better,
// (1-tt*mm)/ee+mm, which is >=1.
// When we take the equation ss*ee+tt*mm=1 modulo
// ee, it becomes
// tt*mm==1 mod ee,
// so one value that would work for tt is the inverse
// of mm modulo ee.
return (1-inverse(mm%ee, ee)*mm)/ee+mm;
}
--Mike Amling
Received on Mon May 1 01:54:16 2006