473,734 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BigInteger.prob ablePrime in C#.Net???

Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
doesn't have the BigInteger class but found that one buddy created
BigInteger class but it is missing some overloading function like
BigInteger.prob ablePrime(). The code of the BigInteger class developed
in the C#.Net can be found here:
http://www.codeproject.com/KB/cs/biginteger.aspx

Quick suggestions are always welcome.
Thanks in advance.
Jul 10 '08 #1
11 10510
On Jul 10, 2:10*pm, imranisb <imran...@gmail .comwrote:
Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
doesn't have the BigInteger class but found that one buddy created
BigInteger class but it is missing some overloading function like
BigInteger.prob ablePrime(). The code of the BigInteger class developed
in the C#.Net can be found here:http://www.codeproject.com/KB/cs/biginteger.aspx
What, exactly, should such a method do?
Jul 10 '08 #2
If you mean the Java BigInteger class and method by that name, then I think
the easiest thing is just wrap that method in a java console app and run it
from c#. I suspect implimenting that method in c# is fairly involved...

"imranisb" wrote:
Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
doesn't have the BigInteger class but found that one buddy created
BigInteger class but it is missing some overloading function like
BigInteger.prob ablePrime(). The code of the BigInteger class developed
in the C#.Net can be found here:
http://www.codeproject.com/KB/cs/biginteger.aspx

Quick suggestions are always welcome.
Thanks in advance.
Jul 10 '08 #3
I wrote a C# interface to GNU GMP (big Number) project. It includes an
interface to "isPrime", which does the probablistic Miller/Rabin test. You
can find it at http://sites.google.com/site/fredm/H...terface-to-gmp.
It uses C++ (dotNet) to make the classes which are then accessible via C#.

If you don't want to use that, I can supply native C# code that does the
test; it uses C# native type (ulong, which is 64 bits -- might not be "big"
enough for your purposes). That code is only about 80 lines long.

If you want to write your own function, look up Miller-Rabin on the net to
see how it works.
"imranisb" <im******@gmail .comwrote in message
news:17******** *************** ***********@59g 2000hsb.googleg roups.com...
Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
doesn't have the BigInteger class but found that one buddy created
BigInteger class but it is missing some overloading function like
BigInteger.prob ablePrime(). The code of the BigInteger class developed
in the C#.Net can be found here:
http://www.codeproject.com/KB/cs/biginteger.aspx

Quick suggestions are always welcome.
Thanks in advance.

Jul 10 '08 #4
Pavel Minaev wrote:
On Jul 10, 2:10 pm, imranisb <imran...@gmail .comwrote:
>Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
doesn't have the BigInteger class but found that one buddy created
BigInteger class but it is missing some overloading function like
BigInteger.pro bablePrime(). The code of the BigInteger class developed
in the C#.Net can be found here:http://www.codeproject.com/KB/cs/biginteger.aspx

What, exactly, should such a method do?
http://java.sun.com/javase/6/docs/ap...bablePrime(int)

would be a good guess.

Arne
Jul 10 '08 #5
Family Tree Mike wrote:
If you mean the Java BigInteger class and method by that name, then I think
the easiest thing is just wrap that method in a java console app and run it
from c#. I suspect implimenting that method in c# is fairly involved...
The easiest would be to do:

using System;

using java.math;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
BigInteger bi = new BigInteger("123 45");
Console.WriteLi ne(bi.isProbabl ePrime(10));
}
}
}

since BigInteger was part of Java 1.1 and therefore exist
in J#.

There is just one problem: the implementation !

It is horrible slow.

Arne
Jul 10 '08 #6
But that isn't available in VS 2008, is it?

"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:48******** *************** @news.sunsite.d k...
Family Tree Mike wrote:
>If you mean the Java BigInteger class and method by that name, then I
think the easiest thing is just wrap that method in a java console app
and run it from c#. I suspect implimenting that method in c# is fairly
involved...

The easiest would be to do:

using System;

using java.math;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
BigInteger bi = new BigInteger("123 45");
Console.WriteLi ne(bi.isProbabl ePrime(10));
}
}
}

since BigInteger was part of Java 1.1 and therefore exist
in J#.

There is just one problem: the implementation !

It is horrible slow.

Arne

Jul 11 '08 #7
Family Tree Mike wrote:
"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:48******** *************** @news.sunsite.d k...
>Family Tree Mike wrote:
>>If you mean the Java BigInteger class and method by that name, then I
think the easiest thing is just wrap that method in a java console
app and run it from c#. I suspect implimenting that method in c# is
fairly involved...

The easiest would be to do:

using System;

using java.math;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
BigInteger bi = new BigInteger("123 45");
Console.WriteLi ne(bi.isProbabl ePrime(10));
}
}
}

since BigInteger was part of Java 1.1 and therefore exist
in J#.

There is just one problem: the implementation !

It is horrible slow.
But that isn't available in VS 2008, is it?
VS 2008 comes with .NET 3.5, .NET 3.5 uses .NET 2.0 CLR, J# runtime
is available for .NET 2.0.

Why should it not be possible to make a ref to vjslib.dll in VS 2008 ?

Arne
Jul 11 '08 #8
On Thu, 10 Jul 2008 03:10:50 -0700 (PDT), imranisb
<im******@gmail .comwrote:
>Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
doesn't have the BigInteger class but found that one buddy created
BigInteger class but it is missing some overloading function like
BigInteger.pro bablePrime(). The code of the BigInteger class developed
in the C#.Net can be found here:
http://www.codeproject.com/KB/cs/biginteger.aspx

Quick suggestions are always welcome.
Thanks in advance.
If you have, or can obtain, a copy of "Practical Cryptography" by
Ferguson and Schneier they give an algorithm in section 11.4

The algorithm is basically very simple:

repeat
pick a random BigInteger in the right range
until (the number you picked is prime)

For reasonably sized numbers you will need a probabilistic prime text,
such as Miller-Rabin and some sort of level of confidence parameter so
you can be sure that your number is prime to better than say 1 in
2^128

Alternatively have a look at the Java source code for ideas, you can
download the Java source from Sun.

rossum

Jul 11 '08 #9
I cannot find such a dll on my system. I'm running VS 2008 pro. I found a
link that says it needs to be separately installed from this link:
http://msdn.microsoft.com/en-us/vjsharp/bb188598.aspx. It isn't clear to me
what version you need to target. In other words, would you need to target
2.0 and lose LINQ to get this?

"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:48******** *************** @news.sunsite.d k...
Family Tree Mike wrote:
>"Arne Vajhøj" <ar**@vajhoej.d kwrote in message
news:48******* *************** *@news.sunsite. dk...
>>Family Tree Mike wrote:
If you mean the Java BigInteger class and method by that name, then I
think the easiest thing is just wrap that method in a java console app
and run it from c#. I suspect implimenting that method in c# is fairly
involved.. .

The easiest would be to do:

using System;

using java.math;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
BigInteger bi = new BigInteger("123 45");
Console.WriteLi ne(bi.isProbabl ePrime(10));
}
}
}

since BigInteger was part of Java 1.1 and therefore exist
in J#.

There is just one problem: the implementation !

It is horrible slow.
But that isn't available in VS 2008, is it?

VS 2008 comes with .NET 3.5, .NET 3.5 uses .NET 2.0 CLR, J# runtime
is available for .NET 2.0.

Why should it not be possible to make a ref to vjslib.dll in VS 2008 ?

Arne
Jul 11 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12981
by: Jerry | last post by:
Hi, I am writing a Java Chatroom application that will implement encryption of messages using the RSA algorithm using the BigInteger class. It uses socket connections to exchange messages. I have managed to generated the Private and Public keys and exchanged public keys and modulus between the clients and server. Please could someone advise me how encrypt a short message, pass the encrypted message across a socket connection and then...
0
1732
by: Krzysztof Adamski | last post by:
Hi, Is it possible in jython to map an PyLong object to other class than BigInteger (i.e. java.lang.Long) ? Thanks for you help, Krzysztof Adamski
4
6403
by: adrin | last post by:
I have to create a c++ class similar to BigInteger from java... but i have no idea, how can i implement big numbers at all(mabye store every digit in list element? :)) how is it properly done? thanks for help
8
2078
by: Nafai | last post by:
Hello I would like you guys to give me the best solution for this problem: class bigInteger { private: vector<char> digits; public: ... bigInteger& operator+=(const bigInteger& x)
0
1444
by: hitler123 | last post by:
can anyone say me how to define BigInteger as a datatype in an xsd. this xsd i am uising in the xmlbeans.
19
6463
by: shana07 | last post by:
I don't understand about this program is doing. Could someone please tell me what it is about. Because I have gcd function in one program that calls this function. Thanks a lot switch (opcode) { case GCD: out = b1.gcd(b2).toString(); break; /** * Returns a BigInteger whose value is the greatest common divisor of * <tt>abs(this)</tt> and <tt>abs(val)</tt>. Returns 0 if * <tt>this==0 &amp;&amp;...
2
2848
by: gemacjr1201 | last post by:
I am creating a GUI for class and need help with my program. My program takes 2 big integers and adds them together. First how do I declare my 2 Big Integers and then add them together? I have read the API docs , but still need help. Thanks! import java.math.BigInteger; public class Integer { private BigInteger IntegerONE; // both entered as strings from GUI private BigInteger IntegerTWO; public Integer() {
2
2780
by: jehugaleahsa | last post by:
Hello: I am currently working on a some simple (not really) classes called BigInteger and BigRational. They are pretty much identical to Java's BigInteger and BigDecimal classes, respectfully. BigRational is really simple and it just maintains a dividend and denominator and then prints out the decimal form when done with the calculation.
6
13571
by: mearvk | last post by:
Does C++ or C have something roughly equivalent to this: http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html What I need is a way to quickly convert between decimal and binary and from char*/string to a numeric representation. Thanks!
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.