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. hiding/encrypting connection string

hiding/encrypting connection string

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netsecurityhelptutorial
2 Posts 2 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.
  • S Offline
    S Offline
    samerh
    wrote on last edited by
    #1

    hi all i am deploying an asp.net application and i want to prevent users from seeing my connection string. I want to hide my user name and password. I googled a little but there is no clear example that i found. I only found theories. Any help with some code, url.. any thing that closes the encryption idea or what ever called to me. thanks in advance.

    K 1 Reply Last reply
    0
    • S samerh

      hi all i am deploying an asp.net application and i want to prevent users from seeing my connection string. I want to hide my user name and password. I googled a little but there is no clear example that i found. I only found theories. Any help with some code, url.. any thing that closes the encryption idea or what ever called to me. thanks in advance.

      K Offline
      K Offline
      Kodanda Pani
      wrote on last edited by
      #2

      Hi, Use the following code to encrypt and decrypt your connection string. public static byte[] Encrypt(byte[] clearData, byte[] Key, byte[] IV) { //create the memory stream MemoryStream ms = new MemoryStream(); //create a crypto service provider Rijndael objrj = Rijndael.Create(); //set the Key and iV values objrj.Key = Key; objrj.IV = IV; //create a crypto ctream CryptoStream cs = new CryptoStream(ms,objrj.CreateEncryptor(),CryptoStreamMode.Write); cs.Write(clearData,0,clearData.Length); cs.Close(); byte[] encryptedData = ms.ToArray(); return encryptedData; } public static byte[] Decrypt(byte[] cypherData, byte[] Key, byte[] IV) { //create the memory stream MemoryStream ms = new MemoryStream(); //create a crypto service provider Rijndael objrj = Rijndael.Create(); //set the Key and iV values objrj.Key = Key; objrj.IV = IV; //create a crypto ctream CryptoStream cs = new CryptoStream(ms,objrj.CreateDecryptor(),CryptoStreamMode.Write); cs.Write(cypherData,0,cypherData.Length); cs.Close(); byte[] clearData = ms.ToArray(); return clearData; }

      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