JOSheaIV 119 C# Addict

Alright this one has me stumpted.

I have a piece of code to do TCP Listening running on a thread that was executed from the ThreadPool, using this little one liner ThreadPool.QueueUserWorkItem(ServerListener);, that will continue to run until a status flag is altered. When the thread has ended I need to clean up some resources. The only thing is I want these done on the main thread, and not within the thread spun up by the ThreadPool. This is to ensure that another piece of code doesn't run that could be counter to what I am doing with closing a connection and disposing of resources.

Is there any way I can call some sort of method on the main thread from another thread, or trigger some event (that would block calls to the class that might for instance reinitialize a variable I am trying to dispose of)?

I know I could use a BackgroundWorker for this, but would rather try to avoid those because when I read about them, the way it's worded, these seem to be intended to be used in relation with Windows Form Components, and not a simple piece of code used to send and recieve messages over TCP.

Thanks for any help.

JOSheaIV 119 C# Addict

Security program to do what exactly? Encrypt a password? Authenticate a key?

JOSheaIV 119 C# Addict

Hey marcolanza24

If I am reading this correctly, you want each individual word as its own element in the collection (in relation to a line). You could try something like

foreach (string line in File.ReadAllLines(@"..\..\InputApriori.txt"))
{
    itemsDataList.Add(new DataSets() { line.Split(new char [] {' '}, StringSplitOptions.RemoveEmptyEntries) });
}

What that does is the foreach loop has a collection of string, each index is one line from the file (the split there being the line break, .NET handles that part). Then what I have done is split the "line" itself on a space. This split returns a collection of strings, or in your case each word on the line. That should produce the results you want.

JOSheaIV 119 C# Addict

Thank you pritaeas. The code I posted there was just used as test code (to show the static property itself doesn't initialize right away). I am just trying understand the underlaying logic of properties better. I use these a lot, but realized when it comes to my static ones (which I don't use often).

Again I have a project that I initialize for instance these static properties when they are first called. They are populated with a collection of data. The reason behind this was the data is constant so once initialized it won't change, and could be used across all classes for the life of the application. However, I don't initialze it all at once to prevent loading time and a larger memory footprint that's needed.

The application I am currently doing this on is more to improve my skills, so I was inquiring more on the details of how static properties work in respect to the items above. Do I really gain the benefit, and how exactly are they working (because in my later example, I see that property doesn't initialize itself right away, why I was using public so I could access both variables externally to test it)

JOSheaIV 119 C# Addict

So while that seems to make sense, here's something interesting.

I rigged up the following piece of code (see below). What was interesting is within a different class, where I tried to access this class (if I recall right I had a generic constructor). Anyway, I could consistently access the class variable (not the property), and never had an issue. The value remained null. It wasn't till I called the property that the exception was thrown.

public static string _TestValue = null;

public static string TestValue
{
    get
    {
        if(_TestValue == null)
        {
            throw new Exception("");
        }

        return _TestValue;
    }
}

So I am wonder, while what you said does make sense, how does this work? I mean usually when you think static, you think initialized at runtime. Yet this property never even tried to do anything with itself until I tried to access it. Are properties more then just a variable?

JOSheaIV 119 C# Addict

Alright I got a question for you all that I just can't seem to figure out if it's working as I expect it to or not.

Recently I have begun re-writing a piece of code I wrote that is used to generate QR Codes (square barcodes). Part of the reason I am doing this is try and improve its performance and memory footprtint, and clean up the code from a maintance point. Now granted it probably isn't a big issue on these, but I am doing it to try and teach myself better coding standards.

Anyway, one of the part is initializing variables only when I need them, even if static. These are constant variables, that won't change, but at the same time, there are multiple of them, so at any time, only one collection might be needed. Here is a snippet of some code I have written.

private static Dictionary<ErrorCorrectionLevel, int []> _NumericLengths;

#region NumericLengths
/// <summary>
/// Get the collection of Numeric Encoding Version Lengths
/// </summary>
private static Dictionary<ErrorCorrectionLevel, int []> NumericLengths
{
    get
    {
        if (_NumericLengths == null)
        {
            _NumericLengths = new Dictionary<ErrorCorrectionLevel, int []>();
            _NumericLengths.Add(ErrorCorrectionLevel.L, new int [] { 41, 77, 127, 187, 255, 322, 370, 461, 552, 652, 772, 883, 1022, 1101, 1250, 1408, 1548, 1725, 1903, 2061, 2232, 2409, 2620, 2812, 3057, 3283, 3514, 3669, 3909, 4158, 4417, 4686, 4965, 5253, 5529, 5836, 6153, 6479, 6743, 7089 });
            _NumericLengths.Add(ErrorCorrectionLevel.M, new int [] { 34, 63, 101, 149, 202, 255, 293, 365, 432, 513, …
JOSheaIV 119 C# Addict

Back in college, on my laptop and desktop, I had NetBeans and Visual Studio 2012 installed on the same machine at the same time. It had no problem what so ever.

JOSheaIV 119 C# Addict

A little addition to Shark_1's post,

You probably will also want to add a Group By onto that select statement. So for instance if you want to see how many occurances there are of the s_monthname in the table, but only return distinct records in relation to the month name (so only 1 record) you could do something like

select s_monthname, count(*) as Total from sample2 GROUP BY s_monthname

Not only will that return the s_monthname value, but the Total will be how many times that a value in that column has occured in the table (but all in one record)

bayron209 commented: yeah yeah.. all in one record will display.. so this is the right syntax? gonna try this one +0
JOSheaIV 119 C# Addict

That's good to hear, and nice having a road map (I should really get back to making my game sometime)

JOSheaIV 119 C# Addict

My advice, use an engine. These are specifically design for the very purpose for people to build their games upon. They take care of all the nitty gritty bits that can bog you down if you tried to do everything yourself (such as rendering, lighting effects, sound and how it is heard depending on factors, ext). Some of the engines out there are pretty amazing and can allow a lot of freedom. For instance, the Unreal engine, it's amazing to see the diversity of titles that have spawned from that.

Speaking on engines a few that come to mind are, Source, Unreal, and Unity. I am pretty sure the Source and Unreal you can get for free, but I do not know the limitations (I've only ever done personally map building with Source, using the Hammer Editor, which is actually rather easy to pick up and work with, but I have seen full fledge games come out of it). One example to point out of engines is Titanfall, which was built on Source. Look at that and Half-Life 2, and you might be surprised to see they were built on the same engine

Also, on a side note, I would write out a basic plan for the game, a road map of what you want it to be. A theme for instance, objectives, what makes it unique, and others that can help you keep focus and prevent you from going on a tangent that ends up becoming wasted time

JOSheaIV 119 C# Addict

Do you have any of the code you have tried? For instance what approaches have you attempted that have caused errors? This can help prevent duplicate work, or possibly finding the bug in what you have tried

JOSheaIV 119 C# Addict

Depending on how the data is stored, it is very possible to reuse these. There are algorithms out there for capturing this data, such as the iris recognition. These are from what I know, publically know (or should be, based on the rules of cryptography).

You pretty much have the bytes that represent someone's fingerprint, in some format

JOSheaIV 119 C# Addict

SO you are running your application on a seperate machine, and have to downlioad a 600+ MB file? That is weird, because .NET has all the libraries needed to connect to a SQL Server database, local or remote. (System.SQL or something like that). How are you connecting to the database exactly? Depending on the libraries might explain it. I know if you use the SMO objects they require additional files

I assume I understood this correctly

JOSheaIV 119 C# Addict

Well I feel silly for not thinking of Teme64's answer. This does indeed seemed to have worked.

JOSheaIV 119 C# Addict

WOW! I can't believe I didn't think of that! I'll give this a try and let you know (might be few days)

JOSheaIV 119 C# Addict

Alright this one is bugging the heck out of.

I am developing some software that can auto generate a solution and projects within. I have the project templates already created (done by another co-worker), and zipped up. I have then added these as an embedded resource into my project. However, no matter what I try to do, I can't figure out how to load in the .zips as a valid Project Template. I just keep getting file can't be found like errors.

Is ther ANYway to do this? I have be searching the net for awhile, however, have had no luck. I can't believe this can't be done.

JOSheaIV 119 C# Addict

I know this is solved, but I wanted to bring something up in that you should really think about the security related to storing these finger prints.

Long story short, my last year of college was a granduate level class on Applied Cryptography. For my final paper I focused on biometics. Anyway, one of the dangers with biometrics is that unlike a password, which if stolen, can be changed (like someone hacks a database), a biometric cannot. That biometric is now useless.

One way to get around this issue was Soft Biometrics. If I remember right (it's been some time), the concept is that you has the results of the biometric value hashed before storing it. This drastically reduces the chances of someone stealing and making the person's biometric now useless. That being said, even hashed, a value can be cracked with enough time, so make sure you implement a top of the line hashing function, and a good Salt

rproffitt commented: Not to mention once I have this, can I use it elsewhere? +7
JOSheaIV 119 C# Addict

So what's the problem exactly? Looks like you spin up one thread and are your way.

You should be aware, that Thread.Sleep(60000). Once you hit that, the thread it's running on is going to sleep for a minute, and any command you try to send it, won't be acknoweldged until you come out of the sleep. I would advise using like a for loop, and sleeping for like 5 ms increments, and checking the flag (and then once you have incremented to pass the 1 min part you go back to the top of your Shutdown == false while loop).

Now that being said, if I am looking at your code correctly, because of this massive sleep, you might have trouble accessing that "Shutdown" property externally. The sleep might brick the whole thing ... BUT, I can't say for sure, I'd have to test that myself to be sure, it's just a guess.

JOSheaIV 119 C# Addict

No offense, but this seems a little fishy.

The way you are posting on every level possible makes me think you are going to try and find anyone. You also claim it's going to be open, but there's a side of me thinking you might be wanting more from it (you should probably have a written contract before you make a move, else some might get the impression you are trying to get free labor).

Again no offense, but the way this is written, has alarms going off in my head like crazy

JOSheaIV 119 C# Addict

I used the initialization to prevent it from blowing an exception. If you try to pull a GetType for a null, it throws an exception. Pritaeas makes a good point, it might be wise to put a null checker, since even if you don't initally set it to null, the user could with a derived class.

Once you start to learn inheritance more, you quickly start looking a little different on how you design things. I really got into it with a custom SQLite library I am developing, but also, some windows form component I have developed which use a lot of repetative code (I actually can't believe I didn't learn it sooner ... now just to find the correct use for interfaces)

JOSheaIV 119 C# Addict

Nah you did it correctly. The reason you got a stack overflow, you were calling print in your Class1, which was calling itself.

Usually you use a virtual/override when you want the base class to function a certain way, but you can override the logic (there is also the abililty to do tricks that Interfacing allows for, in relation to calling a function or what not). However, I do feel that while your example does show a good way to use inheritance, it might be a little over the top for what you need. In your case I think something like this might have worked easier

namespace nSpace
{
    class Base
    {
        protected object val = new object();

        public void Print()
        {
            Console.WriteLine("Printing a " + val.GetType());
        }
    }
    class Class1 : Base
    {
        val = "1";
    }
    class Class2 : Base
    {
        val = 1;
    }
    class Program
    {
        static void Main(string[] args)
        {
            Base[] reg = new Base[2];
            reg[0] = new Class1();
            reg[1] = new Class2();
            foreach (Base r in reg)
            {
                r.Print();
            }
            Console.ReadKey();
        }
    }
}

Here you let the base "Print" do its thing like always, but instead, by using object, you can actually change the type. Now in this example it works vert nicely without any virtual or override because it's a type object.

I can go on about how you can actually use virtual/override in relation to say a custom object, and have the Base class contain a base Item, that an …

ddanbe commented: Knowledge! +15
JOSheaIV 119 C# Addict

Remember that DateTimePicker is most likely pulling the DateTime format based on the cultural settings on the machine. That being said, you have to be careful about have it should expect the format.

That being said, DateTimePicker.Value, expects a value in DateTime format, this is the best move because DateTime types don't care about the culture info once they are set, as they have all those value broken up into properties (like Month, Date, Year, ext). You're goal should be getting the value from the database, and converting it to a DateTime type.

Did you say you tried this?

DateTime AppointmentTime = DateTime.Parse(row.Cells["Appointment Time"].Value.ToString());
JOSheaIV 119 C# Addict

Yeah if you look at your debugging values, you are saying the pattern is "dd-MM-yyyy" but it clear is showing a pattern of dd-MM-yyyy". You probably don't have to use DateTime.ParseExact, I wouldn't be surprised if Parse pulled it fine.

That being said, I would also strongly advise you replace that null with an Invariant Culture value. It's better practice to account of culture differences earlier on, then later and not having a good habit of it.

JOSheaIV 119 C# Addict

I will say this about those stock random number generators. I had one for a screensaver program, I won't go into details, but it invovled populating multiple queues with random information. Despite me priming the generator (pulling like 5000 random numbers ahead of time), I could still see a pattern in the program with each queue matching what another one did like 2 indexes ago. Even after a queue would drain and be repopulated, I'd still see patterns. This was with around a few hundred entries, but still, I am no math genious who can predict patterns easily, and could see it. That's why I took the time to really dive into the RandomOps library, and have been much more impressed.

(On a side note, I should point out that RandomOps was just one possible library. If you go to random.org they have a list of all these libraries for different languages you can use)

I might have to check out this square root solution, looks like a much better approach and maybe something I could utilize.

JOSheaIV 119 C# Addict

One other thought, a more brute force way, since you are doing FIFO, is to create duplicates in the queue. So say you have a unique identifier to specifiy each record type. For a normal random engine you'd have 1 entry in the queue to select from for each record. However, to increase the chances of getting older records, you could create duplicates of these IDs, increasing the chances of them being picked since there are more occurances.

You'd probably have to setup ranges of some sort like "if it's 60 days old have 3 entries for each record".

Also, for your random engine, if you are looking for a good one, check out RandomOps for C#. The author of the library built it so it can actually use random.org as a source of entropy for seeding a random number generator (which happens to be a true random source of entrophy). The site limits you to 1 million bits a day I believe, but if you initialize it once, and then just keep it static that shouldn't be an issue (the author though did design it to fall back and allow to be seeded by another random engine). Of course that's for free users, you can actually purchase more a day if you desire

I have used that library myself many times, and even have a nice wrapper class (the initialization of the random number generator using random.org as an entropy source takes a second or two, but once that's …

JOSheaIV 119 C# Addict

Actually if you are trying to get the DateTime from a string, you should be using the something like DateTime.Parse, DateTime.TryParse, DateTime.ParseExact, or DateTime.TryParseExact

If I remember right, the Convert.ToDateTime, never worked for converting a string to a DateTime. However, I do know for a fact the above ones work. The ParseExact is nice because you can say "hey this input is in this DateTime format", however, the Parse is rather smart and figuring out the pattern on it's own (I've used this for parsing industry regulated barcode, who can have mutlipe DateTime formats)

(By the way, the difference between, Parse and TryParse, is the Parse will thrown an exception if fails, while TryParse returns a true or false, and uses an 'out' for the converted value, much like the other TryParse items)

JOSheaIV 119 C# Addict

ReverendJim, that tool looks nice, I'll have to check that out myself.

Another suggestion, is you could always look on how others do it. There is CUPID as well as Open Hardware Monitor. They both offer the source code or a dev code that you can look at (note that CUPID, my Nortan loves to flag the dev code, so I'd watch that one)

JOSheaIV 119 C# Addict

should be comboBox1.Items.Clear(); That should remove all items in the ComboBox (if that is not working make you are executing it on the correct ComboBox and don't have some code trying to repopulate it before you desire).

JOSheaIV 119 C# Addict

You've pretty much already answered your question. You convert the image to a byte array, and then store it (it's like a varbinary type). Just be aware, this can easily grow the size of your database quickly if the images are large enough.

JOSheaIV 119 C# Addict

So it sounds like you want to populate your ComboBox with all the distinct values from a column.

Look for the event "CellValueChanged" in the DataGridView. This should fire after the cell's value has been edited, and focus has left the cell (so like leaving edit more).

However, I would suggest, that when they leave editing, you get all the distinct values from a column, that way in case they changed one that's no longer present, it's not in the ComboBox. Just google something like "Select Distinct Values Datagridview column" or something like that (make sure you clear the ComboBox first if you do this)

JOSheaIV 119 C# Addict

This can be tricky. It really depends on how the login is done for the page. You would have to log in to the base using your webKitBrowser1, using the code. Unfortantly I can't find the code awhile back, but you should be able to google and see what's possible

(Again depending on how the login logic works, some approaches may not work, for instance, I had one application I used a cURl library, however, to login completely, I had to have a cookie generated ahead of time, but for it to be valid, I had to login though like a web browser normally, to make the cookie valid)

JOSheaIV 119 C# Addict

So if you are trying to programmically click a button, you can do something like btnCalculate.PerformClick();. Is that what you trying to do, is programmically click the button? Or did I misread this?

JOSheaIV 119 C# Addict

So are you trying to create an application to generate possible random numbers that you could then use to create your tickets? Or are you planning to try and find a pattern in the numbers that have been drawn

(I will tell you if it's the 2nd option, you probably won't have much luck, since the lottery numbers are true random, with no known possible way of finding a pattern)

JOSheaIV 119 C# Addict

Are you trying to keep a running counter that every new item you index is on a new row? (kind of like you would do if you inserted into a SQL server database)?

If the code isn't working you may want to check this link
http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm

It appears to be doing exactly what you are trying to do if I am reading this all correctly.

JOSheaIV 119 C# Addict

It appears you are trying to treat you ints as a collection ... which you can probably assume will NOT work. ddanbe does bring up a good idea, that you could use a dictionary.

This gives you a "key" based on the 'i' value (which is kind of like "Number1", "Number2", ext), that you can assign a value to. Just be aware, you can add a new index to a dictionary, but once you do, that key is set and can't be changed. The Value for the key can, however.

You'd have something like

Dictionary<int, int> Number = new Dictionary<int, int>();

for(var i = 1; i < collection.count; i++)
{
    Number.Add(i, collection[i].Number[i]);
}

That should do the trick for you (I am kind of curious what you are trying to do here, as you call the index for the collection and then the index for the Number property, which means in collection index 5, you are accessing the 5th index of the Number property, which I could see turning into an out of bounds type error)

ddanbe commented: Nice advice +15
JOSheaIV 119 C# Addict

He meant more there are libraries out there, external to .NET's default collection you get when you install it, that could provide what you are looking for. I would suggest just googling around.

For instance, here is one I found just googling "C# Library Calender"
http://www.codeproject.com/Articles/168662/Time-Period-Library-for-NET

If you were really ambitious, you could create your own, however, notice I said ambitious, as this wouldn't be a quick coding job (you'd probably use like a TableLayoutPanel, and then create panels for cells. Or you could try a DataGridView, and then have events related to cell clicking).

Usually when I build custom controls like this, they take time as I want to make something rather robust so I could use it in the future (they can take me hours and hours as I write my own events amoung other things)

JOSheaIV 119 C# Addict

So I did some quick Googling real quick, from what I can tell, the Calender control is designed for System.Web.UI, not System.Windows.Form which is what you'd be using for a Windows Form design. It looks like, the MonthCalender is the WindowsForm equivalent of the Calender

JOSheaIV 119 C# Addict

Ahh perfect. Also I see you added a Close to the code.

I should point out that I have read a few articles about closing your connection to a database. They all say it's better to open the connection while you need it, then close it when you are done. Even if this involves a single query.

JOSheaIV 119 C# Addict

I would argue WPFs. They may seem like the best choice, but I should point out they aren't the greatest. They have practically no memory management. I had to write my own disposer pretty much to clean up a nasty memory leak. They are nice, but not always the best choice.

There is another way to do transpancy. You can actually draw on the form itself. I did this for an application once. You could also just draw the missing pieces behind, or have a new panel that you use something like "BringToFront"

JOSheaIV 119 C# Addict

Well first of all your count query has an issue. You have a space after the Username. Notice the last string

string CheckString = @"(SELECT COUNT(*) FROM user WHERE UserName = '" + txtUsername.Text + "')";

Depending the SQL that may or may not matter (I know SQL Server can sometimes disregard trailing spaces). But that's just one.

As for your other error, if you look at the error, it's a casting error. ExecuteScalar by default returns a type object. So the code probably is having some issues trying to type cast it. Try this instead

int Count = Convert.ToInt32(commandCheck.ExecuteScalar());
JOSheaIV 119 C# Addict

Well you 2nd insert your column names, specifically this "acount_name" looks different then the 1st where it's "account_name" (notice the extra c). I don't know if that might be causing some issues or if it was just a typo when you wrote this post

JOSheaIV 119 C# Addict

I see the problem, it's actually two pieces. First of all while you assign the parameter, with the the cmd.Parameters.AddWithValue("@UserName", this.txtUsername.Text)', you never actually call the code to query the database in the first place. You know something like cmd.ExecuteQuery();

Also your comparison probably isn't going to work.

You have if ("UserName" != this.txtUsername.Text), which is saying "if the username entered is not equal to "UserName" inject it into the table (you are comparing the TextBox value to a hardcoded string). I assume your intent was to query the table, and see if any records exist for the name, and if not, insert.

What you should look on doing is querying the table, and seeing if any records were returned. You could do this for instance with a "COUNT" sql command, and use it in relation to an ExecuteScalar call. You could also just query the table, and populate a DataTable with the results, and if the row count on it is greater then 0, then there were matches found (the 2nd is a little more work, but it's nice if you want to build a wrapper class that you can call to run queries and store the results).

Check out this link, it might help you with what you want
http://stackoverflow.com/questions/2807282/getting-mysql-record-count-with-c-sharp

JOSheaIV 119 C# Addict

Don't forget the single quotes around the value if it's a string type column (or similar types). So you'd need to produce a query string like

string QueryString = String.Format("SELECT * FROM TableName WHERE (Name = '{0}')", textBox1.Text);

Make sure you replace "TableName" with the proper name of the table. That will give you the query string you need to run. If it returns back matches, then you know it already exists in the database

JOSheaIV 119 C# Addict

Hello Hamza_13,

Can you please post the code you have written. It's kind of hard to follow exactly what your code is doing just by your original post. It would be also nice to see that you have attempted to do the work, as DaniWeb isn't a place to ask people to write you code for you (this includes school projects)

JOSheaIV 119 C# Addict

This is a rather weird one, becuase if your application is running in 64-bit, then it should be pulling up the 64-bit libraries. Oracle is a stickler for this, and must have identical matchups.

Either that, or the 32-bit libraries are not setup correctly on the system you are working on. We have two products in our office, one that runs 64-bit, and one that runs 32-bit, and when it comes to the Oracle drivers, we had to go through extra work to make sure both were on the system and the applications grabbed the correct architecture (or more they were able to acquire it)

JOSheaIV 119 C# Addict

Nice little piece of code. I like the recurssion piece as well (course I say that with a little bias because I did something like that to and though to myself "wow that was clever of me").

If you do a PictureBox addition, make sure you dispose the Image, and don't just set it to null ... of course this assumes the image isn't referencing an item in memory shared by others (couldn't help myself bringing this up, I've been working a lot with Images in the last few years)

JOSheaIV 119 C# Addict

Using the code you provided you could do something like

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    button2.Enabled = (!String.IsNullOrWhiteSpace(textBox1.Text));
}

That pretty much is saying, if there is text in the TextBox, that isn't just whitespace (like spaces), then enable the Button, but if it is blank or whitespace, disable it.

(Of course you can put your other code in there as well)

Also, you may not want to care calling the base.OnKeyPress(e). This is usually used if you override a virtual event for a component, which should be done really in a seperate class anyway. May I also ask what the purpose is of the 'if' statement in that event?

JOSheaIV 119 C# Addict

So after recovering from being sick, I have finally been able to try some of these approaches.

First of all, Parallel.For doesn't support a BigInteger variable type. However, I did find one work around to this, but the speed was still rather brutally slow

I then tried the Fermat, and this does seem to be MUCH faster. Istill will need to test it with larger numbers. However, seeing that there is a chance it can fail, I will need to continue to research ways around this. (or a fall back once it produces what it believes to be a valid prime) .

Unfortnatly there is some flaw in some logic in the key generation of my code (not sure what, need more tests)

JOSheaIV 119 C# Addict

@jwenting, I beg to differ.

There is a saying about ciphers, "Make the algorithms public, but the keys private". This has been the case for every cipher in history (with the exception of the Caesar Cipher, which is one of the oldest if not oldest cipher). That being said, and RSA encryption is rather easy to implement.

The reason I am not reusing the .NET version of the RSA cipher is because it's not a very good implementation. Specifically the generation of the keys I believe sucks. RSA depends on the p and q value, values that must be very large, truly random numbers, and the .NET version only produces these values about 15 numbers long (that's not large enough). This is why I am doing it myself.

The reason why is because the P and Q values in an RSA encryption are very important. If even one of these values is figured out by a user, the whole entire encryption algorithm will be compromised, and new keys will need to be generated.

There is a research paper out there called "Mining your Ps and Qs" in which the author finds horrible flaws in company’s entropy sources for their devices. Entropy, as you may know, is "randomness", which can be used for instance to seed random number generators. If this source isn't truly random, and risks even the slightest pattern repeating, it can compromise the system. I would strong suggest finding and reading this paper because it points out a …

JOSheaIV 119 C# Addict

@ddanbe, that Parallel.For loop looks like a rather interesting thing to investigate. I have had thoughts about using threads, but couldn't really come up with a good way to split up the number. This, however, might offer a solution to the idea. I'll have to research into these more

@invisal, that will probably be out of the option. The values I am producing can, and do exceed the limits of even a double in C#. I can't recall off the top off my head, but I want to say in some tests I was producing ones over 30 digits in size. I wanted to produce crazy high random numbers to help make the encryption algorithm operate more effectively.

What I have been wondering about, is there some way I can do something like a binary search tree concept. Like take the square of a value, or split it somehow, and have lower branches repeat, creating a recurssive function that tests multiple elements at the same time, but in smaller values. I am pretty sure there's not some simple math behind it, but then again, encryption isn't what it is because of simple math.