// encrypt mod private string RSAEncode(string text) { string srtext = new string(text.Reverse().ToArray()); ; var a = BCHexDec(BitConverter.ToString(Encoding.Default.GetBytes(srtext)).Replace("-", "")); var b = BCHexDec("123456789"); var c = BCHexDec("8adc582addccb2500aad); var key = BigInteger.ModPow(a, b, c).ToString("x"); key = key.PadLeft(256, '0'); if (key.Length > 256) return key.Substring(key.Length - 256, 256); else return key; }
private BigInteger BCHexDec(string hex) { BigInteger dec = new BigInteger(0); int len = hex.Length; for (int i = 0; i < len; i++) { dec += BigInteger.Multiply(new BigInteger(Convert.ToInt32(hex.ToString(), 16)), BigInteger.Pow(new BigInteger(16), len - i - 1)); } return dec; }
是RSA加密,如何把上述代码转为PHP语言?
|