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

📄 primitives.java

📁 RSA is an asymetric method to crypt message. You can use RSA to crypt the key session of symetric me
💻 JAVA
字号:
package rsa;import java.math.BigInteger;public class Primitives {    public Primitives(){    }        public static String I2OSP(BigInteger x,int xLen){        String ret=x.toString(16);        int ret_len=ret.length();        if(ret_len< (2*xLen)){            for(int i=0;i<(2*xLen-ret_len);i++)ret="0"+ret;        }else if(ret_len>2*xLen){            ret="Integer too large";        }        return ret;    }        public static BigInteger OS2IP(String sx){        BigInteger x;        try{            x=new BigInteger(sx,16);        }catch(Exception ec){            x=null;        }        return x;    }     public static BigInteger RSAEP(BigInteger n,BigInteger e,BigInteger m){        BigInteger c;        if(m.compareTo(n)>=0)c=null;        else{            c=m.modPow(e, n);        }        return c;    }        public static BigInteger RSADP(BigInteger n,BigInteger d,BigInteger c){        BigInteger m;        if(c.compareTo(n)>=0)m=null;        else{            m=c.modPow(d, n);        }        return m;    }        public static BigInteger RSASP1(BigInteger n,BigInteger d,BigInteger m){        BigInteger s;        if(m.compareTo(n)>=0)s=null;        else{            s=m.modPow(d, n);        }        return s;    }        public static BigInteger RSAVP1(BigInteger n,BigInteger e,BigInteger s){        BigInteger m;        if(s.compareTo(n)>=0)m=null;        else{            m=s.modPow(e, n);        }        return m;    }}

⌨️ 快捷键说明

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