Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Data type Byte conversion...

Data type Byte conversion...

Scheduled Pinned Locked Moved ASP.NET
tutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    greendragons
    wrote on last edited by
    #1

    I want that value of textbox to be converted into base64 string so that i can sent it to another page as encrypted username from response.redirect....what i used <code>Convert.FromBase64String(textbox1.Text);</code> how to save this converted value and in what data type...and i want it converted into string so that i can send encrypted code to another page and then decrypt it and again save it as string.....please suggest any easy way.....

    A 1 Reply Last reply
    0
    • G greendragons

      I want that value of textbox to be converted into base64 string so that i can sent it to another page as encrypted username from response.redirect....what i used <code>Convert.FromBase64String(textbox1.Text);</code> how to save this converted value and in what data type...and i want it converted into string so that i can send encrypted code to another page and then decrypt it and again save it as string.....please suggest any easy way.....

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Use this Code below

      string str = textbox1.Text;
      string encstr = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(str));
      string decstr = System.Text.Encoding.Unicode.GetString(Convert.FromBase64String(encstr));

      encstr represents the base64 encrypted string which you can pass between pages, and decstr is the string decryption. :rose:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      G 1 Reply Last reply
      0
      • A Abhishek Sur

        Use this Code below

        string str = textbox1.Text;
        string encstr = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(str));
        string decstr = System.Text.Encoding.Unicode.GetString(Convert.FromBase64String(encstr));

        encstr represents the base64 encrypted string which you can pass between pages, and decstr is the string decryption. :rose:

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        G Offline
        G Offline
        greendragons
        wrote on last edited by
        #3

        THNX!!!! alot :) i got my problem solved...but please could you explain it....i can't understand the use of ascii encoding then base64 string use....

        A 1 Reply Last reply
        0
        • G greendragons

          THNX!!!! alot :) i got my problem solved...but please could you explain it....i can't understand the use of ascii encoding then base64 string use....

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Well, Convert.ToBase64String takes a byte array. You need to convert your string to Byte array. You can do it using a for loop and create the Byte array yourself. System.Text.Encoding.Unicode.GetBytes does it for you. :cool: On the contrary, the reverse is Convert.FromBase64String returns a byte[], so again you need to convert Byte array into string. System.Text.Encoding.Unicode.GetString does it for you .. . Hope this help you. :thumbsup::thumbsup:

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          G 1 Reply Last reply
          0
          • A Abhishek Sur

            Well, Convert.ToBase64String takes a byte array. You need to convert your string to Byte array. You can do it using a for loop and create the Byte array yourself. System.Text.Encoding.Unicode.GetBytes does it for you. :cool: On the contrary, the reverse is Convert.FromBase64String returns a byte[], so again you need to convert Byte array into string. System.Text.Encoding.Unicode.GetString does it for you .. . Hope this help you. :thumbsup::thumbsup:

            Abhishek Sur


            My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

            **Don't forget to click "Good Answer" if you like to.

            G Offline
            G Offline
            greendragons
            wrote on last edited by
            #5

            Thnx lol i got it....:)

            A 1 Reply Last reply
            0
            • G greendragons

              Thnx lol i got it....:)

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              If that answered helps you, then Please don't forget to Click on Good Answer :-D

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups