Results 1 to 14 of 14

Thread: simple encription question

  1. #1
    B2E
    Guest

    simple encription question

    I am sure this question is simple so it should not take you smart guys long. I have some text in a RichTextBox1 and i want to turn each character(letter) into a number then i am going to add a number to it say "1" and then save it to a file as a long set of numbers, when i want to read the info the program will subtract the number "1" and then turn the corresponding number back into a letter(character) and put them back in the richtextbox1 does anyone know how to do this? or maybe an easier way to go about it in vb .net

    THANKS!!!

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    This kind of encryption is very easy to crack.
    The framework provides special classes for almost uncrackable encryption, including the rijndael algorithm, which is one of the best.

    Have a look at the System.Security.Cryptography Namespace.
    I think with VB.NET it is more easy to use the (good) build in encryption methods, then make one of your own.
    I think you must be able to find some samples on the web. I haven't used these classes myself yet.

  3. #3
    B2E
    Guest

    I know that it is easy

    Yea i know that the original way that this would work would be easy to crack....but if i can figure out how to turn each caracter(letter) into a corresponding number or integer then (cause i love high level math) i could write an algorithm that would be very hard to crack.

    If anyone knows how to turn each caracter into a srting then let me know thanks!!

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    I believe the Asc and Chr functions still work in Vb.NET.

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Also the classes in the System.Text Namespace could be of help, especially the ASCIIEncoding Class.
    The GetBytes method can convert a string into a byte aray.

  6. #6
    B2E
    Guest

    ???

    O.k. if you could tell me how to pic on each little character in a string say for instance the string is "This is a test" what would the code look like to get each individual character

    CODE:
    for 0 to richtextbox1.text.lenght

    something in here to get the first(t) then the next(h) then the next(i) and so on so forth....(s)...( )...(i)..(s)..( )...(a)...ect

    next

    what do i need to do to get each character one at a time if i new how to do that i think i could take it fromt here

    thanks

  7. #7
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    I you want to split it into single characters, you need an array of chars, but I thought you wanted to make numbers out of them, so to turn a string intom an array of bytes, you could use something like this:

    not tested, I don't have VB.NET installed were I am right now.

    VB Code:
    1. Dim AE as new System.Text.ASCIIEncoding
    2. Dim MyString as String = "This is a test"
    3. Dim bArr() as Byte
    4.  
    5. bArr() = AE.GetBytes(MyString)

    bArr now contains the ASCII values for each character in the string (ranging from 0 to 255)

  8. #8
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    VB Code:
    1. Dim AE As New System.Text.ASCIIEncoding()
    2.         Dim MyString As String = "This is a test"
    3.         Dim AnotherString As String
    4.         Dim bArr() As Byte
    5.  
    6.         bArr = AE.GetBytes(MyString)
    7.         ' now the string "This is a test" is converted to an array of bytes
    8.         ' so every character in the string is now a number between 0 and 255 in the array
    9.         ' you can encrypt it now, and save it to file
    10.         ' after reading it back from file, and decrypting it,
    11.         ' you can convert the bytearray back to a string like this
    12.         AnotherString = AE.GetString(bArr)
    13.         MsgBox(AnotherString)

  9. #9
    B2E
    Guest

    Thanks!

    Thanks a lot

  10. #10
    B2E
    Guest

    anouther question!

    ok say that i wanted to take each member in the array and add a number to it like the number 1 or 2 and then save it like that and when i open the file to read it i would subtract whatever the number i added to each member of the array was and then convert it back to a string. How would i go about doung that?

    thanks agian

  11. #11
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    Why don't you use the XOR operator, you can make a pretty good encripter/decripter if you have a good imagination.... I use it a lot when I want to encript data... if you make a good algoritm with it, it's won't be easy to crack at all....

  12. #12
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    Example ?

  13. #13

    Cool heres a good example of the RSA algorithm in .NET

    http://www.planet-source-code.com/vb...=782&lngWId=10

    I'm also the author of the code in this link,.

    Best regards
    Svein

  14. #14
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    ok try my encryption example if you are looking for encryption and vice versa
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width