Secret Message Encoding in C#

One of my friend asked me to write a program that encode a message and make it difficult to understand, kind or secret message.

Message: Hi I am Sunil

First of all there should not be any white space, so our message now looks like “HiIamSunil”. Now we have to make a rectangle form of the message where rows can not be greater than columns.




Now the encoded message is “Hmi iSl Iu an”. There should be a white space between every word.

Other examples:

Input: Chillout

Output: Clu hlt io

Input: Good day Sunil

Output: Gdu oan oyi dSl

Here is my solution:

            string str = “Good day Sunil”.Replace(” “, “”);
            int len = str.Length;
            double result = Math.Sqrt(len);
            double numCol = Math.Ceiling(result);
            double numRow = Math.Floor(result);
            int colNo = (int)numCol;
            char[] arr = str.ToCharArray();
            string encodeMsg = string.Empty;
            string temp;
            for (int i = 0; i < colNo; ++i)
                temp = string.Empty;
                for (int j = i; j < len; )
                    temp += arr[j];
                    j += colNo;
                encodeMsg += temp + ” “;


30 thoughts on “Secret Message Encoding in C#

  1. Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there’s even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That’s right AUTOMATICALLY, just watch this 4minute video for more information at. Seo Plugin


  2. There are some fascinating deadlines on this article but I don’t know if I see all of them center to heart. There is some validity but I will take maintain opinion till I look into it further. Good article , thanks and we want extra! Added to FeedBurner as effectively


  3. I was suggested this web site by my cousin. I am not sure whether this post is written by him as nobody else know
    such detailed about my trouble. You’re incredible! Thanks!


  4. Hello There. I found your blog using msn.

    This is an extremely well written article. I will make sure to bookmark it and
    return to read more of your useful information.

    Thanks for the post. I will certainly comeback.


  5. Greate post. Keep writing such kind of info on your page.
    Im really impressed by your blog.
    Hi there, You’ve performed a great job. I’ll definitely digg it and in
    my view recommend to my friends. I am confident they’ll be benefited from this site.


  6. Hi there! Would you mind if I share your blog with my myspace group?
    There’s a lot of folks that I think would really appreciate your content. Please let me know. Cheers


  7. Fascinating blog! Is your theme custom made or did you download it from somewhere?
    A design like yours with a few simple adjustements would
    really make my blog jump out. Please let me know where you
    got your theme. Thanks


  8. Thanks on your marvelous posting! I certainly enjoyed reading it, you happen to be a great author.
    I will be sure to bookmark your blog and will eventually come back from now on.
    I want to encourage you to continue your great posts, have a nice holiday weekend!


  9. Greetings! Very helpful advice in this particular post!
    It’s the little changes that will make the biggest changes. Thanks a lot for sharing!


  10. We’re a group of volunteers and opening a new scheme in our community. Your website offered us with valuable info to work on. You have done a formidable job and our whole community will be thankful to you.


  11. An outstanding share! I’ve just forwarded this onto a colleague who has been conducting a little homework on this. And he in fact bought me breakfast simply because I found it for him… lol. So allow me to reword this…. Thank YOU for the meal!! But yeah, thanks for spending time to talk about this matter here on your internet site.


  12. Thanks for writing Secret Message Encoding in C# | Code World
    Technology. I’m certainly certainly motivated that some one might piece of writing something like this. The item reminds myself a little of duke sweatpants that is another history totally. Enjoy a wonderful day!


  13. I simply desired to point out I honestly understand a person’s writing skills. It’s good
    to read someone whom provides a comprehension of syntax plus punctuation on-line.
    I will tell many others about Secret Message Encoding in C# |
    Code World Technology. Cheers!


  14. You are so cool! I don’t suppose I’ve read something like that before.
    So nice to find another person with a few genuine thoughts on this subject.
    Seriously.. thank you for starting this up. This website is
    something that is required on the internet, someone with a
    little originality!


  15. Good day! This post could not be written any better! Reading through this
    post reminds me of my good old room mate! He always kept talking about this.
    I will forward this write-up to him. Pretty sure he will have a good read.
    Many thanks for sharing!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s