Click here to Skip to main content
15,886,815 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
In image steganography the inputted text is converted into equivalent ascii and that ascii is converted into byte and again byte to bit array...How can i do this in vb.net?
Posted

1 solution

In general case, the text cannot be "converted" into ASCII, because .NET supports Unicode, and ASCII only supports Unicode characters with code points below 127.

Just forget ASCII, it's gone; use any of the UTF encodings.

Remember that they are all equivalent, but resulting binary code is different (in memory, Unicode is represented using UTF16LE). And this is not a bit array, but array of bytes. (You never need a bit array anyway). You need to use System.Text.Encoding.ToBytes(string) to get byte array and System.Text.Encoding.GetChars to go back to string again (use resulting char array as the argument of a string constructor:

http://msdn.microsoft.com/en-us/library/ds4kkd55.aspx[^],
http://msdn.microsoft.com/en-us/library/khac988h.aspx[^],
http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx[^],
http://msdn.microsoft.com/en-us/library/ttyxaek9.aspx[^].

Of course, you will need to use one of concrete UTF classes derived from the abstract class Encoding; I would prefer UTF-8 as the most compact, especially if many characters of your text are withing the ASCII repertoire, which is most typically the case. Also, this UTF is the standard for most application fields.

—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 14-Jan-13 11:20am    
OK, your reply tells me that you really have no a clue of programming, most elementary things. You cannot move on, and no answer will help you before you learn the basics.

I already answered in full.

Do you understand that an array of bit is the same thing? What, you have no idea how to extract a bit from byte?
There is not such data type as "bit", do you know that? You can use Boolean, but array of Boolean will be sparse, only one bit will be used. You are going to loose order of magnitude of memory space. Even if this is ok, this is plain silly...

—SA
Member 9753615 14-Jan-13 21:08pm    
Ya ofcourse... I'm a beginner..Sorry for disturbing...
Sergey Alexandrovich Kryukov 14-Jan-13 21:44pm    
No problems at all. We always start with something Please see the very recent discussion:
http://www.codeproject.com/Questions/527615/BitpluswiseplusoperationsplusinplusC-23.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900