程序代写代做代考 algorithm Screenshot

Screenshot

Pseudocode

repeatSquare(l x, e, n){
y=1;
while(e>0){
if((e%2)==0){
x=(x*x)%n;
e=e/2;

}
else{
y=(x*y)%n;
e=e-1;
}
}
return y;
}

encript(m, e, n, nounce)
{
len = m.length
c[0] = nounce;

for ( i=1; i <= len; i++) { c[i] = repeatSquare(m[i-1] ^ c[i-1], e, n); c[i] = repeatSquare(m[i-1] ^ c[i-1], e, n); } return c; } decript(c, d, n) { len = c.length for (int i=1; i < len; i++) { m[i - 1] = repeatSquare(c[i], d, n) ^ c[i-1]; } return m; } Server: Bind sorcket, wait connection. When Connected to client. Send(n, e). format: 8 bytes array, first 4 bytes is the integer n, second 4 bytes is the integer e. receive(enc_nonce) nonce = repeatSquare(enc_nonce, d, n) send(“OK”). Receive(enc_message). Dec_message = decript(enc_message, d, n). send(Dec_message). Client: Connect to server. Receive(n, e). nonce = rand() % 100; enc_nonce = repeatSquare(nonce, e, n); send(enc_nonce); receive(OK). getMessageFromUser(message). enc_message = encrypt(message, e, n, nonce). Send(enc_message). receiveReply(). Bonus I have implemented correctly the Extended Euclidean Algorithm. The test function is written in server_gcc/test_extend_gcd.cpp. After make, also generate a test_extend_gcd.exe to test the function. /docProps/thumbnail.jpeg