Answer the question
In order to leave comments, you need to log in
RSA decryption?
RSA algorithm
n = 517815623413379 e = 12371
ив = 12788138155374656626484111508435839351545312207685619856968320863251613810
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace RSA
{
class Program
{
static String codes2string(String str)
{
StringBuilder text = new StringBuilder();
Byte[] bytes = new Byte[str.Length / 2];
for(int i=0;i<str.Length/2;i++)
{
String code = str.Substring(2 * i, 2);
bytes[i] = Byte.Parse(code);
}
return ASCIIEncoding.ASCII.GetString(bytes);
}
static void Main(string[] args)
{
BigInteger e = 12371;
//BigInteger e = 12341;
BigInteger n = 517815623413379;
//BigInteger n = 565570077646207;
//Факторизация n: в гугле Wolphram alpha factor(n)
BigInteger p = 2432363;
//BigInteger p = 1546379;
BigInteger q = 212885833;
//BigInteger q = 365738333;
BigInteger phi = (p - 1) * (q - 1);
Console.WriteLine("phi");
Console.WriteLine("{0}", phi);
//Обратный элемент d в кольце e,phi https://planetcalc.ru/3311/
BigInteger d = 81621537934331;
//BigInteger d = 143672396238821;
Console.WriteLine("{0}", (d * e) % phi);//Здесь должна выводится единица
String[] c_text = "127881381553746 566264841115084 358393515453122 076856198569683 20863251613810".Split(' ');
//String[] c_text = "277140870674302 260217431481485 329310844916399 448964498705119".Split(' ');
StringBuilder text = new StringBuilder();
StringBuilder c_text_ = new StringBuilder();
foreach(String c_str in c_text)
{
BigInteger c_msg = UInt64.Parse(c_str);
BigInteger msg = BigInteger.ModPow(c_msg, d, n);
text.Append(msg.ToString());
BigInteger c_msg_ = BigInteger.ModPow(msg, e, n);
c_text_.Append(c_msg_.ToString());
}
Console.WriteLine(c_text_);
Console.WriteLine(codes2string(text.ToString()));
Console.ReadKey();
}
}
}
n = 565570077646207 e = 12341
ив = 277140870674302260217431481485329310844916399448964498705119
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace RSA
{
class Program
{
static String codes2string(String str)
{
StringBuilder text = new StringBuilder();
Byte[] bytes = new Byte[str.Length / 2];
for(int i=0;i<str.Length/2;i++)
{
String code = str.Substring(2 * i, 2);
bytes[i] = Byte.Parse(code);
}
return ASCIIEncoding.ASCII.GetString(bytes);
}
static void Main(string[] args)
{
//BigInteger e = 12371;
BigInteger e = 12341;
//BigInteger n = 517815623413379;
BigInteger n = 565570077646207;
//Факторизация n: в гугле Wolphram alpha factor(n)
//BigInteger p = 22432363;
BigInteger p = 1546379;
//BigInteger q = 212885833;
BigInteger q = 365738333;
BigInteger phi = (p - 1) * (q - 1);
Console.WriteLine("phi");
Console.WriteLine("{0}", phi);
//Обратный элемент d в кольце e,phi https://planetcalc.ru/3311/
//BigInteger d = 1433315859233483;
BigInteger d =143672396238821;
Console.WriteLine("{0}", (d * e) % phi);//Здесь должна выводится единица
//String[] c_text = "127881381553746 566264841115084 358393515453122 076856198569683 20863251613810".Split(' ');
String[] c_text = "277140870674302 260217431481485 329310844916399 448964498705119".Split(' ');
StringBuilder text = new StringBuilder();
StringBuilder c_text_ = new StringBuilder();
foreach(String c_str in c_text)
{
BigInteger c_msg = UInt64.Parse(c_str);
BigInteger msg = BigInteger.ModPow(c_msg, d, n);
text.Append(msg.ToString());
BigInteger c_msg_ = BigInteger.ModPow(msg, e, n);
c_text_.Append(c_msg_.ToString());
}
Console.WriteLine(c_text_);
Console.WriteLine(codes2string(text.ToString()));
Console.ReadKey();
}
}
}
Answer the question
In order to leave comments, you need to log in
Yes, the whole thing was in the c_text variable, or rather, in its division into substrings with spaces, here is the code that decrypts everything as it should
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace RSA
{
class Program
{
static String codes2string(String str)
{
StringBuilder text = new StringBuilder();
Byte[] bytes = new Byte[str.Length / 2];
for(int i=0;i<str.Length/2;i++)
{
String code = str.Substring(2 * i, 2);
bytes[i] = Byte.Parse(code);
}
return ASCIIEncoding.ASCII.GetString(bytes);
}
static void Main(string[] args)
{
BigInteger e = 12371;
//BigInteger e = 12341;
BigInteger n = 517815623413379;
//BigInteger n = 565570077646207;
//Факторизация n: в гугле Wolphram alpha factor(n)
BigInteger p = 2432363;
//BigInteger p = 1546379;
BigInteger q = 212885833;
//BigInteger q = 365738333;
BigInteger phi = (p - 1) * (q - 1);
Console.WriteLine("phi");
Console.WriteLine("{0}", phi);
//Обратный элемент d в кольце e,phi https://planetcalc.ru/3311/
BigInteger d = 81621537934331;
//BigInteger d = 143672396238821;
Console.WriteLine("{0}", (d * e) % phi);//Здесь должна выводится единица
String[] c_text = "127881381553746 56626484111508 435839351545312 207685619856968 320863251613810".Split(' ');
//String[] c_text = "277140870674302 260217431481485 329310844916399 448964498705119".Split(' ');
StringBuilder text = new StringBuilder();
StringBuilder c_text_ = new StringBuilder();
foreach(String c_str in c_text)
{
BigInteger c_msg = UInt64.Parse(c_str);
BigInteger msg = BigInteger.ModPow(c_msg, d, n);
text.Append(msg.ToString());
BigInteger c_msg_ = BigInteger.ModPow(msg, e, n);
c_text_.Append(c_msg_.ToString());
}
Console.WriteLine(c_text_);
Console.WriteLine(codes2string(text.ToString()));
Console.ReadKey();
}
}
}
default CSP RSA , RSACng , RSAEngine didn't fit? The latter contains the source code for the implementation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question