rsa2.cpp 459 B

1234567891011121314151617181920212223
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int decode(int c,int d,int n){int m=1;for(int i=0;i<d;i++){m=(m*c)%n;}return m;}
  4. char m[1024];
  5. int c[1024];
  6. int i,d,n;
  7. char a;
  8. int main(){
  9. cout<<"n:";
  10. cin>>n;
  11. cout<<"d:";
  12. cin>>d;
  13. cout<<"cidhertext:";
  14. while(scanf("%d",&c[i++])!=EOF)
  15. {
  16. a=cin.get();
  17. if(a!=' ') break;
  18. }
  19. for(i=0;c[i]!=0;i++){m[i]=decode(c[i],d,n);}
  20. cout<<m;
  21. system("pause");
  22. return 0;
  23. }