How do I perform the inverse of a number to be applied in the encryption and decryption in multiplication encoding in MATHLAB? With GUI.

조회 수: 2 (최근 30일)
How do I perform the inverse of a number to be applied in the encryption and decryption in multiplication encoding in MATHLAB? With GUI.

답변 (1개)

John D'Errico
John D'Errico 2022년 11월 9일
A gui is irrelevant. It is YOUR job to write a gui, if you need one.
You compute the inverse of a number by dividing it into 1. So 1/x is the inverse of x.
Perhaps you are asking about a modular multiplicative inverse. If so, then you can use GCD. Read the help for GCD.
help gcd
Does a multiplicative inverse for a number that is NOT relatively prime to the modulus? No. That is, 2 does not have a multiplicative inverse mod 6. There is no integer x such that mod(2*x,6)==1.
So a multiplicative inverse, of the form mod(a*x,B)==1, if a and b are relatively prime. If that is the case, then the gcd(a,b)==1. GCD will return that. But then look at the other outputs to GCD. GCD returns also C and D, such that
G = a*C + b*D
If we take that equation modulo b, then we see it reduces to
G = a*C
where we know that G == 1, since a and b were relatively prime. So now we have
mod(a*C,b) == 1
Therefore C is the multiplicative modular inverse of a in the ring of integers modulo b.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by