⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rsa.java

📁 rsa加密算法的JAVA实现
💻 JAVA
字号:
import java.math.*;
import java.io.*;

/*
p=43
q=59
n=2537
t=2436
e=13
d=937
*/

public class RRR2{
    public static void main(String args[])throws IOException{
        BigInteger n= new BigInteger("3157");
        BigInteger d= new BigInteger("647");
        BigInteger e= new BigInteger("17");
        BigInteger x;
        String str="";
        BigInteger y;
        
        int i;
        byte[] b= new byte[256];
        int temp;
        int[] enc=new int[256];
        int count=System.in.read(b);

    for(i=0;i<count-2;i++)                 
    System.out.print(" "+b[i]);            
    System.out.println("");
    for(i=0;i<count-2;i++)                
    System.out.print(" "+(char)b[i]);      
    System.out.println("");
       
    for(i=0;i<count-2;i++)                
    {
        str="";
        str+=b[i];                           
        x=  new BigInteger(str);             
        System.out.print(x.pow(d.intValue()));
        y=x.modPow(d,n);                     
        enc[i]=y.intValue();                 
        System.out.print("-->"+y+"\n");
    }
    System.out.println("");
    for(i=0;i<count-2;i++)                
    {
        str="";
        str+=enc[i];                        
        x=new BigInteger(str);               
        y=x.modPow(e,n);                     
        temp=y.intValue();                   
        System.out.print((char)temp);        
    }
   
   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -