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. General Programming
  3. C#
  4. textBox -to- Binary Registry

textBox -to- Binary Registry

Scheduled Pinned Locked Moved C#
windows-adminquestion
7 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.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    How can take the text from the textBox and save it as a Binary data in the registry? Many Thanks, Jassim Rahma

    A 1 Reply Last reply
    0
    • J Jassim Rahma

      How can take the text from the textBox and save it as a Binary data in the registry? Many Thanks, Jassim Rahma

      A Offline
      A Offline
      Adrian Hall
      wrote on last edited by
      #2

      Hey Jassim, The Text is stored within textbox.Text property. Look in the C# articles for "QuickRegistry" and use that for storage. -Adrian

      J 1 Reply Last reply
      0
      • A Adrian Hall

        Hey Jassim, The Text is stored within textbox.Text property. Look in the C# articles for "QuickRegistry" and use that for storage. -Adrian

        J Offline
        J Offline
        Jassim Rahma
        wrote on last edited by
        #3

        but this will just create a plain text and not binary one? how to convert it to binary? Jassim

        J 1 Reply Last reply
        0
        • J Jassim Rahma

          but this will just create a plain text and not binary one? how to convert it to binary? Jassim

          J Offline
          J Offline
          Jeff J
          wrote on last edited by
          #4

          In order to store something as a REG_BINARY type using .Net, it needs to be passed as a byte array. Getting a byte array from a string is as simple as: byte[] bytArray = System.Text.Encoding.Unicode.GetBytes(textBox.Text); Then pass bytArray into a RegistryKey's SetValue() function: MyRegKey.SetValue("MyBinaryEntry", bytArray); The CLR will automatically detect that the type is a byte array, and set the type accordingly. Retrieving that value will return a byte array also, not a string. Cheers

          J 1 Reply Last reply
          0
          • J Jeff J

            In order to store something as a REG_BINARY type using .Net, it needs to be passed as a byte array. Getting a byte array from a string is as simple as: byte[] bytArray = System.Text.Encoding.Unicode.GetBytes(textBox.Text); Then pass bytArray into a RegistryKey's SetValue() function: MyRegKey.SetValue("MyBinaryEntry", bytArray); The CLR will automatically detect that the type is a byte array, and set the type accordingly. Retrieving that value will return a byte array also, not a string. Cheers

            J Offline
            J Offline
            Jassim Rahma
            wrote on last edited by
            #5

            But this will not encode it and it will be easy for anyone to read it? how can have it encoded in the same code?

            J 1 Reply Last reply
            0
            • J Jassim Rahma

              But this will not encode it and it will be easy for anyone to read it? how can have it encoded in the same code?

              J Offline
              J Offline
              Jeff J
              wrote on last edited by
              #6

              If you feel it's too easy for someone to read the binary data, there are any number of encryption algorithms out there. You can apply one before placing the data into the registry.

              J 1 Reply Last reply
              0
              • J Jeff J

                If you feel it's too easy for someone to read the binary data, there are any number of encryption algorithms out there. You can apply one before placing the data into the registry.

                J Offline
                J Offline
                Jassim Rahma
                wrote on last edited by
                #7

                But will it be easy for someelse to decrypt it? I need to save a system pssword, what do you recommend? Jassim

                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