Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2004, 04:42 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default what data type in vb.net holds more thab 256 bits

I am developing a project for sending an encrypted data over a LAN using RSA. i should have two large prime numbers say P and Q and then say that n = P*Q. then say that a value phi =(P-1)*(Q-1)
and find a value e such that 1<e<phi and the gcd(e,phi)=1.
the problem is i should have a value d such that
e*d mod phi = 1 . i always get an error saying that arthimitic operation flows.
 i have done this

Dim p,q As Long
Dim e1,d As Long
Dim n,phi As Long
Dim x, y As Long
        Dim i As Long


        Randomize()

        x = 10000 + Rnd() * 10000

        While (Not isprime(x))

            x = 10000 + Rnd() * 10000

        End While
        p = x


        Randomize()

        y = 10000 + Rnd() * 10000
        While (Not isprime(y))

            y = 10000 + Rnd() * 10000
        End While
        q = y


        n = p * q

        phi = (p - 1) * (q - 1)


        Dim e11 As Long
        Randomize()

        e11 = 1 + Rnd() * phi


        While (gcd(e11, phi) <> 1)

            e11 = e11 + 1
        End While
        e1 = e11

        Dim d1 As Long
        Randomize()

        d1 = 1 + Rnd() * phi

        While (e1 * d1 Mod phi <> 1)'here the problem occurs
            d1 = d1 + 1
        End While
        d = d1




 
Old November 8th, 2004, 05:35 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default

For a start off, I wouldn't use Longs because they only hold integer numbers. You should be using doubles, or decimals, for floating point operations like this. Try changing all your variables to doubles and I don't think you'll get Arithmetic overflows any more.





Similar Threads
Thread Thread Starter Forum Replies Last Post
DoDragDrop holds system Koeno Pro Visual Basic 2005 5 August 31st, 2008 04:33 PM
Type.GetType does not work in VB.NET. Please help jayaraj123 VB.NET 2 June 3rd, 2008 06:07 AM
default(System.Type) does this exist in VB.NET 2k5 Peace2u ASP.NET 2.0 Basics 0 August 18th, 2006 06:51 AM
Data List in vb.net mistry_bhavin General .NET 0 August 6th, 2004 11:03 PM
Data Type error but it is the correct type Mitch SQL Server 2000 2 March 19th, 2004 11:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.