rsa2.cpp 477 B

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