Thread: help whit encoding files in windwos forms

  1. #1
    Registered User
    Join Date
    Feb 2010
    Location
    holland
    Posts
    6

    Question help whit encoding files in windwos forms

    hello everybody ,(sorry for my basd english )
    i'm trying to make a program that stores passwords in a encoded text file, but i cant encode it. and i have no idea where i have to search for.
    readgards. carlon

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    What kind of encoding? If the file is already encoded, you first need to decode it and then encode it again.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Location
    holland
    Posts
    6
    i dont know recomend me something ive tried ascii but it didint work out

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    A few questions that you should answer before we continue:
    • What do you mean by an "encoded text file"?
    • Do you have control over this "encoding" format?
    • What is the purpose of storing passwords in this file?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Also, "encoding" is just a way of representing information, and is not at all a method of implementing security. If you are dealing with passwords, you may want to be "encrypting" instead.
    ive tried ascii but it didint work out
    How did it not "work out"? ASCII is a simple human-readable, plain-text. So if you did a simple output to a file, its being encoded as ASCII. Other methods of encoding, to support Unicode, is UTF8, UTF16, UTF32. UTF8 is a very popular and efficient method of encoding. There are other, non-portable methods such as Windows-specific encodings, Mac-specific encodings, etc.

    Again, you may just want "encryption", so if thats the case do a simple search for C++ encryption algorithms/examples. Encrypting can be as simple as taking a character, adding one to it, and storing it. In order to decrypt it, you do the inverse function, so you subtract 1 from it. So "secret" would be encrypted as "tfdsfu". Of course this is a very weak encryption, though.

  6. #6
    Registered User
    Join Date
    Feb 2010
    Location
    holland
    Posts
    6
    Quote Originally Posted by nadroj View Post
    Also, "encoding" is just a way of representing information, and is not at all a method of implementing security. If you are dealing with passwords, you may want to be "encrypting" instead.How did it not "work out"? ASCII is a simple human-readable, plain-text. So if you did a simple output to a file, its being encoded as ASCII. Other methods of encoding, to support Unicode, is UTF8, UTF16, UTF32. UTF8 is a very popular and efficient method of encoding. There are other, non-portable methods such as Windows-specific encodings, Mac-specific encodings, etc.

    Again, you may just want "encryption", so if thats the case do a simple search for C++ encryption algorithms/examples. Encrypting can be as simple as taking a character, adding one to it, and storing it. In order to decrypt it, you do the inverse function, so you subtract 1 from it. So "secret" would be encrypted as "tfdsfu". Of course this is a very weak encryption, though.
    yes that is what i ment but can you explain me how

  7. #7
    Registered User
    Join Date
    Mar 2010
    Posts
    11
    If you want simple encryption, then replace each alphabets with some other alphabets or symbol, like a = @@#, b = @#@ etc and then store it. Then when you decrypt it, just reverse the process... ?

  8. #8
    Registered User
    Join Date
    Feb 2010
    Location
    holland
    Posts
    6
    Quote Originally Posted by Prads View Post
    If you want simple encryption, then replace each alphabets with some other alphabets or symbol, like a = @@#, b = @#@ etc and then store it. Then when you decrypt it, just reverse the process... ?
    thanx


    more solutions are always welcome

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You still have not answered this question: what is the purpose of storing passwords in this file?

    Furthermore, are you just doing this for learning purposes, or are you actually trying to write say, a password manager for your own use for real?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by chikaij View Post
    yes that is what i ment but can you explain me how
    I gave a very trivial example in my previous post. Again, that example is, for encrypting you can add some constant to each character (say add 1). Thus, for decrypting you do the inverse: you subtract 1. So an input character 'a' is encrypted as 'b'.

    The type of encryption you need, I think, heavily relies on the application. If you just want to learn about it for your own benefit or personal use, then some simple one that you write is good enough. If you're writing some public real-world application, then you'd want an actually secure one, then you'd be best off using an existing one (search for encryption algorithms/libraries). Any useful encryption algorithm is heavily mathematical with a lot of theoretical foundations, and it would be extremely difficult to write a useful one yourself. However, if you're working on a Masters or PhD in Computer Science or Math, then this is an excellent route to explore.

  11. #11
    Registered User
    Join Date
    Feb 2010
    Location
    holland
    Posts
    6
    Quote Originally Posted by laserlight View Post
    You still have not answered this question: what is the purpose of storing passwords in this file?

    Furthermore, are you just doing this for learning purposes, or are you actually trying to write say, a password manager for your own use for real?
    the purpose is that you can easely stroe passwords and the reason i wnat to encrypt it is becauser i dont want peaple to read it

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by chikaij
    the purpose is that you can easely stroe passwords and the reason i wnat to encrypt it is becauser i dont want peaple to read it
    Of course. But here's the point: if you want to store the passwords in order to implement say, some kind of authentication system, then you would satisfy the need for secrecy by using a cryptographic hash, possibly with a "salt", because you just need to compare the hash digests in order to authenticate.

    But if you want to store the passwords in order to implement say, a "password safe", then you would need to use an encryption algorithm, and the user would need to supply some kind of password so that the secret keys of the encryption algorithm would ultimately be available for decryption (i.e., you cannot just store the secret keys in the clear, otherwise the whole scheme would be useless).

    So, it is not just a matter of "oh, I want to store passwords in a file such that people reading the file cannot read them; what algorithm do you suggest?" The bigger picture of what you are trying to do should be clear.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  2. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM
  3. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  4. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM
  5. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM

Tags for this Thread