#c++ euclidean algorthm // modular inverse help
1 messages · Page 1 of 1 (latest)
Ok sry
does DM typing go 2x as fast or what?
i didn’t know dm had word count too like damn
You can send multiple messages to add all information you need
And please read and follow the #📄・posting-guidelines. They will help you ask for help properly.
That's a nice homework. Can you please explain more in details what you need help with exactly? What have you tried? What don't you understand? What prevents you from achieving you goal? ...
Ok sorry. We're use to people sending their homework with nothing else.
Check the #📄・posting-guidelines. It shows how to properly send code
We can see them don't worry
ok thank u sorry if the code itself is messy I lost my mind writing it
@fresh basalt @undone wave do either of y’all think you could help me 😞
Not right now. Add more details about what you're trying to do more exactly, why it's not working and where in the code it could be great for other or us to help you
Again, I recommend that you look at the #📄・posting-guidelines and make sure you post follows them
I don’t understand what the output of the code would be
From the instructions
I think it's really nice to understand the details of RSA,
but seriously, anyone should use a proper crypto library in production,
not cook their own, within reason
😬
hi- i updated this code, now it’s mostly right but my assert isn’t working
https://sourceb.in/v0FiTzj6pj this is my code
im having issues with the encrypting and decrypting functions, by using rsa algorithms
the encrypting of the number doesnt work and ive tried anythign can someone pls look at the code with a fresh set of eyes :((
im almost done
What do you mean "it doesn work" what doesn't work? Can you please explain what you want and what you get that isn't right.
You tried everything? What have you tried? Can you explain what you tried and why it didn't work?
Please read and follow the #📄・posting-guidelines when asking for help. It takes 2 minutes to read and will save us a lot of time ping ponging 🏓 questions.
the encrypting of the message does not work. the encrypt and decrypt function are not working. i have tried multiple different ways to try and present the formula to change them and it doesn’t give me the output I should be getting.
Hi @gusty wigeon, Can you review your RelativelyPrime() function ?
You need e value = (p-1)(q-1)
I think you are close to solving the assignment; if you review your instructions again; you will find your error right away
I hope that helps!
hi thank you for answering me
So should I call the function to get E?
or maybe do relativelyprime(phi);?
I think you can set your p and q as random values; and calculate your e = RelativelyPrime(p, q).
The e should be RelativelyPrime to (p-1)*(q-1); which is a prime number closer to it!
||
std::vector<int> relativelyPrime(int p, int q) {
std::vector<int> result;
phi = (p - 1) * (q - 1);
for (int i = 1; i < phi; ++i) {
if (gcd(i, phi) == 1) {
result.push_back(i);
}
}
return result;
}||
I don't think this would work for any p/q values over 32-bit 😬
That’s true @naive rivet, but the assignment is just for 32 bit integers
so you might need ~8 GiB of RAM (~2 billion * 4 bytes = 32 bits after removing even numbers 😛 )
i hate c++ sm how do i get good
yes this is exactly what i did thanks i just saw this
int phi = (P - 1) * (Q - 1);
int PQ = P * Q;
// e is equivalent to the relative prime of phi: (p-1)*(q-1)
int e = RelativelyPrime (phi);
// d is equal to inverse modular of e and phi
int d = inverse (e, phi);
that’s what i submitted