Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Need Help with my project [Encrpyting program]


Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2012, 03:10 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default Need Help with my project [Encrpyting program]


Hi guys, I'm currently in year 12 and I received my major project for this year and I have no ideas how to code program . Please help, it dues in the next four weeks. Question is attached! ( no viruses )

Thanks guys
Attached Files
File Type: pdf IMG.pdf (73.6 KB, 12 views)
Reply With Quote
  #2  
Old 03-31-2012, 05:22 AM
TRSDOSBasic79's Avatar
TRSDOSBasic79 TRSDOSBasic79 is offline
Contributor
 
Join Date: Oct 2003
Location: Pennsylvania
Posts: 422
Default

I see your project, however I will not do it for you. Neither will others here. This is not your first project so exactly what is your stumbling point? Show what you have written so far.
Reply With Quote
  #3  
Old 04-08-2012, 03:59 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

I'm so sorry for this very late reply, I haven't done anything because I wasn't good at coding but here's what I wonder: Assuming that I already have a private key file which contains ASCII codes, how am I going to code the Open button to whether load the private key file and load the user's messages to the program

Here is my screen design (I was very stupid because I forgot to create another Load button to load my private key file, so now I have to code for the Open button to whether load the private key file and load the user's messages)
Attached Images
File Type: png menu2.png (18.4 KB, 12 views)
Reply With Quote
  #4  
Old 04-08-2012, 06:19 AM
TRSDOSBasic79's Avatar
TRSDOSBasic79 TRSDOSBasic79 is offline
Contributor
 
Join Date: Oct 2003
Location: Pennsylvania
Posts: 422
Default

Show some code as to what you have done so far and lets see where you are having the issue. Generally a simple way to encrypt is to just 'XOR' the values to encrypt and then 'XOR' the values again to return the original value.
Reply With Quote
  #5  
Old 04-08-2012, 07:32 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 6,297
Default

soloko2412,

This is a teaching forum. We wll not do your homework for you. You have to make an effort to read and understand the material.

On the other hand.

If you have a specific question such as "how do I read text from a file?" We can point you to tutorials on the topic or if you post code you have written we can help you correct it. We can also explain how programming works at a general level so you can build your knowledge on a good foundation.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #6  
Old 04-10-2012, 05:19 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

Hi guys, I didn't ask you to code all the functions for me so don't be misunderstanding .

I'm so stuck and I don't even know where to begin: When I click the Open button, firstly It will load the private key file, secondly it will load the user's message. And then using that private key file which is loaded, to encrypt user's message T_T, I JUST NEED SOME IDEADS
Reply With Quote
  #7  
Old 04-10-2012, 11:48 AM
TRSDOSBasic79's Avatar
TRSDOSBasic79 TRSDOSBasic79 is offline
Contributor
 
Join Date: Oct 2003
Location: Pennsylvania
Posts: 422
Default

Quote:
Originally Posted by soloko2412 View Post
Hi guys, I didn't ask you to code all the functions for me so don't be misunderstanding .

I'm so stuck and I don't even know where to begin: When I click the Open button, firstly It will load the private key file, secondly it will load the user's message. And then using that private key file which is loaded, to encrypt user's message T_T, I JUST NEED SOME IDEADS


Looks like you have the idea. Lets say the key is "29 43 21 08 16 05" and the message is "The quick brown fox jumps over the lazy dog"

When you click open and the user's message and key displays like my example, you could add the keys together and then XOR each letter in the message one at a time to the key sum. Then display the encrypted message.

To decode, use the same key and just XOR the encrypted message one letter at a time to return it to normal.
Reply With Quote
  #8  
Old 04-12-2012, 04:50 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

Thank you!

I solved the easiest thing in the program which is Open the private key file and user's message and now I'm up to creating the private key file and I have no ideas how to format it.

My assessment says: "The encryption method should use a simple substitution method. It should be set out in the following format."

The Character - Space - The code - EOL
A - Space - 4Gh - EOL

So I opened notepad I've been staring at it without knowing what I'm doing. Please help!
Reply With Quote
  #9  
Old 04-13-2012, 04:53 AM
TRSDOSBasic79's Avatar
TRSDOSBasic79 TRSDOSBasic79 is offline
Contributor
 
Join Date: Oct 2003
Location: Pennsylvania
Posts: 422
Default

Well if your key is a number lets say 3, you could find the asc value of each character and add the key to the value then convert the value back to the character.

if you have the message "car"
The asc value of the letter "c" is 67 so add the key which is three to 67 we get 70. which is the letter "f"

c = f
a = d
r = u

That is just one simple possibility.
You also could pre generate an array of substitutional values you wish to access.
Reply With Quote
  #10  
Old 04-15-2012, 03:20 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

I understand what you're trying to say but the point is how do I type (format) the ascii codes into Notepad? Because the program requires its user to load the private key file which is created as *.txt. I've one example, can you please check it, I appreciate
Attached Files
File Type: txt privatekey.txt (292 Bytes, 3 views)

Last edited by soloko2412; 04-15-2012 at 03:48 AM.
Reply With Quote
  #11  
Old 04-15-2012, 08:29 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 6,297
Default

The simplest of substitution encryptions is to swap each letter in a sentence for another fixed letter.

A N
B E
C L
...

"CAB" would be encrypted as "LNE"

Filling your text file with each letter of the alphabet and a scrambled list of the same letters would fullfill the requirement just as I've shown above.

If you read them from the file into a 2D array you will have a look up table for converting to and from an encryption.

If you read each line of file text into a string variable using the LINE INPUT statement you can get the leftmost character by using
LEFT(<string variable>,1) and the rightmost character by using
RIGHT(<string variable>,1) .

To step through each letter in a sentence you would use the Mid() function in a loop.

---

There is a simpler way to do the look up if you use the ASC() function but perhaps your instructor is saving that for a later lesson.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 04-15-2012 at 08:52 AM.
Reply With Quote
  #12  
Old 04-15-2012, 02:00 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,862
Default

I'm pretty sure the instructor gave fairly detailed requirements for the program, so that the instructor can feed a key file and process messages through the system to see if it produces the specified result.
All the "help" you've been given so far have been different approaches to encrypting a file, and look up table and if you implemented any of them will no likely get a low score on the project.

The project, as defined by the instructor, is more complicated than any of the suggestion.
Any single unencrypted letter input can produce a variable number of characters output.
The brief example in the pdf file shows two characters being encoded with 3 characters and a third encoded with 4 characters.
Using a variable number of output characters for an input character makes it harder for someone to break since (assuming they don't have access to the "key" file"), won't know how many characters are in your original string, or where the "character" boundries are in the encrypted string, since the number of characters in the encrypted character is variable.

That also make is harder on you to decode an encrypted string, since you have to compare a number of characters against your key list to find a match.
Also, if any of your keys for a given character are a subset of the key for another letter, that can be an issue as you may get a match on the shorter key and choose that letter, rather than choosing the longer key that may be found later.

When decoding, you may have to try all keys at each spot, and if you get more than one match, either choose the longer match, if you know the keys are unique enough that no possible two letter combinations will combine to produce a sequence that would produce a substring that would match a key for a single character.
Or you may have to keep the multiple matches, and try each "branch" to see if you eventually find a branch that doesn't decode, so eliminate it.

The project sounded initially a bit simple for a major year 12 project, but looking at the actual requirements show that it is worthy.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #13  
Old 04-15-2012, 02:22 PM
dilettante's Avatar
dilettante dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,328
Default

Since the requirements are to use Pascal, VB.Net 2008, or some open sores compiler I'm wondering why this thread is continuing in a Classic VB forum instead???

I suspect whoever wrote that meant to say "free" compiler, but it is amazing how clueless people can be.
Reply With Quote
  #14  
Old 04-15-2012, 08:26 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,862
Default

Quote:
Originally Posted by dilettante View Post
Since the requirements are to use Pascal, VB.Net 2008, or some open sores compiler I'm wondering why this thread is continuing in a Classic VB forum instead???

I suspect whoever wrote that meant to say "free" compiler, but it is amazing how clueless people can be.
I suppose you're right.
The compiler being used wasn't specified, so could be put in Misc languages or the .Net side.
The Form definitely looks like .Net, so .Net it will be.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #15  
Old 04-16-2012, 09:47 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 6,297
Default

Ah well I don't remember seeing that pdf attachment in the original post.
That information does change things.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #16  
Old 04-18-2012, 04:01 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

Well thank all you guys, I don't know how to show my appreciation . This project importantly counts to my ATAR (mark I have to get to get into uni) so the next part I'll try to do it. But before I get away, I have two more last question, I've been asking several people about which computing languages I should learn nowadays and they said: Net and Java and some even said "Don't study, it's too late :|". What do you guys think?

And second last question is: In my project, how do I code the part where the user encrypt their message after the private key file has been loaded (Just give me ideas and examples)
Reply With Quote
  #17  
Old 04-18-2012, 09:55 AM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,862
Default

Quote:
Originally Posted by soloko2412 View Post
... some even said "Don't study, it's too late :|". What do you guys think?)
In the late 70's or very early 80's, I had mentioned to my father at some point that I would like to get a job programming computers when I got out of the Navy. He talked with a programmer (probably COBOL) at his work which was a major Furniture manufacturer.
The programmer told him that programming was going to be a dead end soon and there was not much of a future to it. Soon you would be writing requirements in some high level manner and the computer would produce the code to be run, so programmers would no longer be necessary.

Fortunately, I like programming for the sake of programming, not just as a way to make money, so I continued anyway and have been pretty much writing software for over 30 years now, and it still pays the bills.

I don't think the age of the software writer is going to be gone any time soon.

Quote:
Originally Posted by soloko2412 View Post
...how do I code the part where the user encrypt their message after the private key file has been loaded (Just give me ideas and examples)
That seem's obvious, but if not obvious then the question must be vague.

If the encrypt option is selected, then you should use the StringBuilder class, since it is made to buildup a string efficiently, to collect the encryption characters.
You would loop through the source string character by character, looking up the encryption key for that character and (using the StringBuilder class) append that key to your output string.
Once all the input characters are processed. Convert the StringBuilder string object to a regular string and display it in your output window, and save it, or whatever else you need to do with it.

The trickier part, it seems to me, is the reverse case where given a jumble of characters, finding the variable length keys to convert back into a single character. If you can guarantee that no shorter key matches the start of any longer key, then it shouldn't be that difficult since you can just compare the keys against the current sequence, but if that is not guaranteed, then you will have to compare all keys to see if you have duplicate matches, then find a way to resolve them.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #18  
Old 04-19-2012, 03:08 AM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

Thank man . I think I will learn NET

Well, I don't think these above questions are the last questions ). I just recognized one error: I use StreamReader to load the private key file and user's message simultaneously so once the user clicks Open, the message and the private key file will be displayed simultaneously on its own text box/listbox but the thing is if a user types the message and then click Open to load the private key file, it will be an error.

Last edited by soloko2412; 04-19-2012 at 03:13 AM.
Reply With Quote
  #19  
Old 04-19-2012, 09:07 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 6,297
Default

soloko,

We cannot troubleshoot a problem by loose description alone.

Our hands are tied until you start posting the code with which you are having problems.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #20  
Old 04-19-2012, 09:30 PM
soloko2412 soloko2412 is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default

Sorry I forgot:

Code:
 PrivateKey = New IO.StreamReader("C:\" & txtMessage.Text & "privatekey.txt")
        While (PrivateKey.Peek() > -1)
            lsbPrivateKey.Items.Add(PrivateKey.ReadLine)
        End While
        PrivateKey.Close()


        Message = New IO.StreamReader("C:\" & txtMessage.Text & "user.txt")
        While (Message.Peek() > -1)
            txtMessage.Text = Message.ReadToEnd()
        End While
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->