none
How do I convert just the text within the quotes( from ) base64String? RRS feed

  • Question

  • Hello, Vikram Manjare

    I don't mean to be a bother, I just keep getting the ( int, byte, char, string and array confused. 

    Can you fix this code to convert text between quotes from base64. I don't really need to use regx.

    int firstQuoteIndex = line.IndexOf("\"");
    if (firstQuoteIndex > 0)
    {
        int secondQuoteIndex = line.LastIndexOf("\"");
        string interText = line.Substring(firstQuoteIndex + 1, secondQuoteIndex - firstQuoteIndex - 1);
        byte[] mc = Encoding.Unicode.GetBytes(interText);
        if (mc.Length > 0)
        {
            string base64String = Convert.ToBase64String(mc);
            string newline1 = line.Substring(0, firstQuoteIndex);
            string newline2 = "\"" + base64String + "\"";
            string newline3 = line.Substring(secondQuoteIndex + 1);
            line = newline1 + newline2 + newline3;
        }
    }

    I am working on a decompiler  for the extension (.dxe)  to (.dsf).

    but I am having a lot of trouble with it.

    I'm not as good of a coder as you are, so I was wondering if I sent you a (.dxe) file  and a (.dsf) file

    would you help me with it.

    Thank you very much for your help



    • Edited by dxe2dsf Sunday, April 22, 2018 3:48 AM
    Sunday, April 22, 2018 3:44 AM

Answers

  • Encode

                                    int firstQuoteIndex = line.IndexOf("\"");
                                    if (firstQuoteIndex >= 0)
                                    {
                                        int secondQuoteIndex = line.LastIndexOf("\"");
                                        string interText = line.Substring(firstQuoteIndex + 1, secondQuoteIndex - firstQuoteIndex - 1);
                                        byte[] mc = Encoding.UTF8.GetBytes(interText);
                                        if (mc.Length > 0)
                                        {
                                            string base64String = Convert.ToBase64String(mc);
                                            string newline1 = line.Substring(0, firstQuoteIndex);
                                            string newline2 = "\"" + base64String + "\"";
                                            string newline3 = line.Substring(secondQuoteIndex + 1);
                                            line = newline1 + newline2 + newline3;
                                        }
                                    }
    

    Decode

                                    int firstQuoteIndex = line.IndexOf("\"");
                                    if (firstQuoteIndex >= 0)
                                    {
                                        int secondQuoteIndex = line.LastIndexOf("\"");
                                        string interText = line.Substring(firstQuoteIndex + 1, secondQuoteIndex - firstQuoteIndex - 1);
                                        if (interText.Length > 0)
                                        {
                                            byte[] plainByte = Convert.FromBase64String(interText);
                                            string plainText= Encoding.UTF8.GetString(plainByte);
                                            string newline1 = line.Substring(0, firstQuoteIndex);
                                            string newline2 = "\"" + plainText + "\"";
                                            string newline3 = line.Substring(secondQuoteIndex + 1);
                                            line = newline1 + newline2 + newline3;
                                        }
                                    }
    
    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by dxe2dsf Sunday, April 22, 2018 5:42 AM
    Sunday, April 22, 2018 4:22 AM

All replies

  • Encode

                                    int firstQuoteIndex = line.IndexOf("\"");
                                    if (firstQuoteIndex >= 0)
                                    {
                                        int secondQuoteIndex = line.LastIndexOf("\"");
                                        string interText = line.Substring(firstQuoteIndex + 1, secondQuoteIndex - firstQuoteIndex - 1);
                                        byte[] mc = Encoding.UTF8.GetBytes(interText);
                                        if (mc.Length > 0)
                                        {
                                            string base64String = Convert.ToBase64String(mc);
                                            string newline1 = line.Substring(0, firstQuoteIndex);
                                            string newline2 = "\"" + base64String + "\"";
                                            string newline3 = line.Substring(secondQuoteIndex + 1);
                                            line = newline1 + newline2 + newline3;
                                        }
                                    }
    

    Decode

                                    int firstQuoteIndex = line.IndexOf("\"");
                                    if (firstQuoteIndex >= 0)
                                    {
                                        int secondQuoteIndex = line.LastIndexOf("\"");
                                        string interText = line.Substring(firstQuoteIndex + 1, secondQuoteIndex - firstQuoteIndex - 1);
                                        if (interText.Length > 0)
                                        {
                                            byte[] plainByte = Convert.FromBase64String(interText);
                                            string plainText= Encoding.UTF8.GetString(plainByte);
                                            string newline1 = line.Substring(0, firstQuoteIndex);
                                            string newline2 = "\"" + plainText + "\"";
                                            string newline3 = line.Substring(secondQuoteIndex + 1);
                                            line = newline1 + newline2 + newline3;
                                        }
                                    }
    
    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by dxe2dsf Sunday, April 22, 2018 5:42 AM
    Sunday, April 22, 2018 4:22 AM
  • Thank you, it works perfectly as usual.

    Let me know in a email if you want to help me with the decompiler

    I left my email address in the question before this one.

    Sunday, April 22, 2018 5:45 AM
  • I shall always help as much as possible on this forum & you can always find solutions from the number of  experts on this forum.
    Sunday, April 22, 2018 7:51 AM