Connection string encryption in VB.Net

After hours of tests I’ve succeeded in ConnectionString encryption in asp.net. I’m not sure if code will work because I’ve done vb.net encryption in my test local website. What more, I’ve made vb.net websites for fun to learn something new.

Attention! This post has been published on my old website that has been down. I’m archiving old not verified posts for possible future use. Please be careful when using this post content.

The issue is I’ve run code on localhost – I hasn’t been checked on external server. I don’t know how the encryption works with MySQL located in external server, how the encryption key is storage, where etc.?

My encryption websites source:

Thanks to this code following actions will be done:

  • Adding Connection String to file Web.config
  • Adding encryption code of Connection String
  • Connection String will be encrypted
  • We connect MySQL database
  • Records from MySQL will be selected and added to GridView

In my test I’ve added event button to page to encrypt or decrypt ConnectionString. First ConnectionString has to be added to Web.config file between <configuration> and </configuration>

Adding Connection String to Web.config file:


<connectionStrings>
   <add name="MySql" connectionString="Data Source=Localhost; Database=tornado; Uid=User; Pwd=Pass;"  providerName="MySql.Data.MySqlClient" />
</connectionStrings>

ConnectionString has to be named. In my project it was MySql because I’m connecting MySQL database. Also ProviderName has to be added this is MySql.Data.MySqlClient related to Imports MySql.Data.MySqlClient.

Button encryption code (sorry – but I’m not sure of this code):

Imports System.Configuration
Imports System.Web.Configuration 

Shared Sub ToggleWebEncrypt()

   ' Open the Web.config file.
   Dim config As Configuration = WebConfigurationManager. _
     OpenWebConfiguration("~") 

   ' Get the connectionStrings section.
   Dim section As ConnectionStringsSection = DirectCast( _
       config.GetSection("connectionStrings"), _
       ConnectionStringsSection)
 
   ' Toggle encryption.
   If section.SectionInformation.IsProtected Then
       section.SectionInformation.UnprotectSection()
   Else
       section.SectionInformation.ProtectSection( _
         "DataProtectionConfigurationProvider")
   End If 

   ' Save changes to the Web.config file.
   config.Save()
End Sub

Encrypted Web.config file view:

<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
   <EncryptedData>
     <CipherData>
       <CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl……………</CipherValue>
     </CipherData>
   </EncryptedData>
</connectionStrings>

MySQL test connection and GridView fill:

Imports MySql.Data.MySqlClient
Imports System.Data
Imports System.Configuration
Imports System.Web.Configuration

   Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 

       Dim dt As New DataTable

       ' Open the Web.config file.
       Dim config As Configuration = WebConfigurationManager. _
         OpenWebConfiguration("~") 

       ' Get the connectionStrings section.
       Dim section As ConnectionStringsSection = DirectCast( _
           config.GetSection("connectionStrings"), _
           ConnectionStringsSection) 

       ' Toggle encryption.
       If section.SectionInformation.IsProtected Then
           section.SectionInformation.UnprotectSection() 

           Dim conn As MySqlConnection = New MySqlConnection() ' forgot source

           conn.ConnectionString = ConfigurationManager.ConnectionStrings("MySql").ConnectionString 

           Try
               conn.Open()

               Dim adapter As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM tornadolokacje", conn)

               adapter.Fill(dt)
               GridView1.DataSource = dt
               GridView1.DataBind() 

           Catch ex As Exception
               MsgBox(ex.Message)
           End Try
       Else
           MsgBox("Conneection String decryption problem.")
       End If
   End Sub

215 thoughts on “Connection string encryption in VB.Net

  1. Pingback: Power to Choose Alternative

  2. Pingback: buy/order real oxycodone 80mg 30mg 15mg online pharmacy cheap no script legally for pain, anxiety in USA UK Canada Australia overseas overnight delivery

  3. Pingback: money wealth

  4. Pingback: hydromorphone for sale online overnight shipping

  5. Pingback: order real adipex 37.5mg tablets for sale next day shipping pharmacy

  6. Pingback: cach chon keo bong da

  7. Pingback: danh de online uy tin

  8. Pingback: Buy 2C-B Research chemical powder Online for sale near me in USA Canada UK Australia overnight delivery cheap

  9. Pingback: eatverts.com

  10. Pingback: ti le chap bong da

  11. Pingback: cách bắt đề kép

  12. Pingback: mơ thấy rắn đánh đề gì

  13. Pingback: game bai poker doi thuong

  14. Pingback: UNICCSHOP.BAZAR

  15. Pingback: replica watches

  16. Thanks for your article on the traveling industry. I might also like to add that if you’re a senior considering traveling, it truly is absolutely important to buy travel cover for retirees. When traveling, older persons are at greatest risk of experiencing a health care emergency. Obtaining right insurance coverage package for the age group can look after your health and provide you with peace of mind.
    dang ky 188bet

  17. Pingback: pinewswire

  18. Pingback: 홀덤사이트

  19. Pingback: concerta 18 mg pills for sale overnight delivery cheap

  20. Pingback: vicodine pills for sale usa

  21. Pingback: blazing trader review

  22. Pingback: frontier airlines Phone Number

  23. Pingback: bitcoin evolution review

  24. Pingback: River poker

  25. Pingback: w88 lite

  26. Pingback: mơ thấy ao nước đánh con gì

  27. Pingback: w88club

  28. Pingback: nằm mơ thấy con rết là điềm gì

  29. Pingback: mơ thấy ba ba

  30. Pingback: mơ mình chết đánh con gì

  31. Pingback: Pomeranian breeders

  32. Pingback: 홀덤사이트

  33. Pingback: sonsofheaven.com

  34. Pingback: mơ thấy người cha đã mất

  35. Pingback: Smith and Wesson guns in stock

  36. Pingback: hopeheating.com

  37. Pingback: masterdomino99

  38. Pingback: ตู้แปลภาษา

  39. Pingback: mo thay vang

  40. Pingback: 먹튀검증업체

  41. Pingback: silicone sex dolls for sale

  42. Pingback: buy cialis canada

  43. Pingback: buy levitra from india

  44. Pingback: cialis ordering

  45. Pingback: pfizer viagra buy

  46. Pingback: cialis mail order pharmacy

  47. Pingback: cialis mail order australia

  48. Pingback: buy cialis online best price

  49. Pingback: order original cialis online

  50. Pingback: cialis 5mg tablet

  51. Pingback: where can u buy cialis

  52. Pingback: cialis sale 20mg

  53. Pingback: buy cialis toronto

  54. Pingback: buy cialis online viagra

  55. Pingback: ppirdtgn

  56. Pingback: where can i buy cialis online safely

  57. Pingback: hoe lang is viagra werkzaam

  58. Pingback: azithromycin chlamydia how long does it take to cure

  59. Pingback: buying cheap cialis online

  60. Pingback: viagra cheap

  61. Pingback: canadian pharmacy cialis 20mg

  62. Pingback: cialis for daily use

  63. Pingback: viagra precio

  64. Pingback: how to buy cialis online from canada

  65. Pingback: reddit essay writing service

  66. Pingback: how to write a thesis for a research paper

  67. Pingback: where can i pay someone to write my essay

  68. Pingback: essay on the help

  69. Pingback: business ethics illinoi shadow process essay

  70. Pingback: canadian pharmacy cialis 20mg

  71. Pingback: cialis online daily

  72. Pingback: canadian pharmacy cialis 20mg

  73. Pingback: where to buy amoxicillin 500mg

  74. Pingback: lasix furosemide

  75. Pingback: zithromax pak

  76. Pingback: stromectol tablets for humans for sale

  77. Pingback: ventolin over the counter

  78. Pingback: buy viagra online

  79. Pingback: cheap viagra

  80. Pingback: coupons for viagra

  81. Pingback: viagra falls

  82. Pingback: cialis online pharmacy

  83. Pingback: viagra and alcohol

  84. Pingback: viagra prices

  85. Pingback: snorting viagra

  86. Pingback: viagra single packs

  87. Pingback: cialis copay card

  88. Pingback: buy doxycycline 100mg

  89. Pingback: prednisolone with benadryl

  90. Pingback: cialis coupon

  91. Pingback: clomid hot flashes

  92. Pingback: viagra gay sex

  93. Pingback: viagra boner

  94. Pingback: dapoxetine in bangladesh

  95. Pingback: 150 mg viagra

  96. Pingback: viagra alternative

  97. Pingback: otc diflucan walgreens

  98. Pingback: sildenafil 100mg price

  99. Pingback: levitra

  100. Pingback: synthroid action

  101. Pingback: viagra sex

  102. Pingback: sophia viagra nude

  103. Pingback: propecia online pharmacy

  104. Pingback: viagra expiration potency

  105. Pingback: mom gave viagra by accident

  106. Pingback: revenue per year viagra 2022

  107. Pingback: does 60mg sildenafil help erections

  108. Pingback: dosage for cialis

  109. Pingback: accidentally took viagra mom help

  110. Pingback: viagra from india info

  111. Pingback: sildenafil is made from what

  112. Pingback: viagra cum milking

  113. Pingback: can i use viagra

  114. Pingback: dog ate viagra south africa

  115. Pingback: neurontin strengths

  116. Pingback: sildenafil generic 50 mg

  117. Pingback: cialis dosage reddit australia

  118. Pingback: cialis purchase online usa

  119. Pingback: metformin liver

  120. Pingback: best price for sildenafil

  121. Pingback: cialis ingredients australia

  122. Pingback: paxil for fibromyalgia

  123. Pingback: plaquenil tinnitus

  124. Pingback: amoxicillin dosage sinus infection

  125. Pingback: dosage amoxicillin

  126. Pingback: azithromycin classification

  127. Pingback: how long for celebrex to work

  128. Pingback: celebrex 200mg price

  129. Pingback: does cephalexin affect inr

  130. Pingback: keflex generic name

  131. Pingback: side eddects duloxetine

  132. Pingback: cymbalta and elavil

  133. Pingback: cheap viagra 100mg canada

  134. Pingback: order viagra 50mg

  135. Pingback: order cialis generic online

  136. Pingback: cialis

  137. Pingback: real cialis for sale

  138. Pingback: viagra india price

  139. Pingback: acheter viagra 200

  140. Pingback: viagra generic name south africa

  141. Pingback: cialis expiration period

  142. Pingback: cheap cialis pills australia

  143. Pingback: metformin 1g

  144. Pingback: comprar sildenafilo 100 mg teva

  145. Pingback: sildenafil best price uk

  146. Pingback: viagra online purchase india

  147. Pingback: finasteride medication

  148. Pingback: buying sildenafil 100mg

  149. Pingback: acheter viagra pfizer 100mg

  150. Pingback: wo buy cheap generic viagra

  151. Pingback: snorting cialis australia

  152. Pingback: cheap propecia generic

  153. Pingback: how to order cialis from india

  154. Pingback: sildenafil online canada

  155. Pingback: 100 viagra pills australia

  156. Pingback: viagra 50 coupon

  157. Pingback: sildenafilo india comprar

  158. Pingback: sildenafil troche dosage

  159. Pingback: buy generic cialis canadian pharmacy

  160. Pingback: viagra 100mg price canada

  161. Pingback: buy cialis 36 hour online

  162. Pingback: impotence pills

  163. Pingback: pills for ed

  164. Pingback: medication canadian pharmacy

  165. Pingback: cialis 20mg for sale

  166. Pingback: costco online pharmacy

  167. Pingback: buy cialis ebay

  168. Pingback: buy cialis tadalafil uk

  169. Pingback: generic cialis daily pricing

  170. Pingback: buy online generic

  171. Pingback: no prescription tretinion gel

  172. Pingback: how to delete tinder account

  173. Pingback: cash in advance hendersonville

  174. Pingback: what is the active ingredient in viagra

  175. Pingback: lisinopril brand name cost

  176. Pingback: buy shipping canada

  177. Pingback: free dating sites for soldiers

  178. Pingback: zestoretic tabs

  179. Pingback: when will there be generic cialis

  180. Pingback: brand levitra cialis viagra add to cart

  181. Pingback: cialis pris

  182. Pingback: generic cialis canadian

  183. Pingback: canadian overnight pharmacy review

  184. Pingback: tadalafil vs cialis reviews

  185. Pingback: buy cialis in miami

  186. Pingback: online pharmacy without a prescription

  187. Pingback: pharmacy tech practice tests online

  188. Pingback: 30 day free cialis

  189. Pingback: buy cialis without perscription

  190. Pingback: buy cheap cialis overnight

  191. Pingback: how to buy cialis online from canada

  192. Pingback: prescription without a doctor's prescription

  193. Pingback: generic tadalafil tablets

  194. Pingback: where can i buy valtrex

  195. Pingback: viagra meaning

  196. Pingback: Google

  197. Pingback: what is the best ed pill

  198. Pingback: buy cialis wholesale

  199. Pingback: viagra prank

  200. Pingback: cialis pharmacy australia

  201. Pingback: sildenafil recall

  202. Pingback: cheap online pharmacy

  203. Pingback: what cialis does

  204. Pingback: sildenafil 200mg price

  205. Pingback: batman pinball machine

  206. Pingback: buying viagra online

  207. Pingback: Weed Wax

  208. Pingback: PARROTS FOR SALE

  209. Pingback: software review

  210. Pingback: FLOUR MILL

Leave a Reply

Your email address will not be published. Required fields are marked *