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. How Encrypt and discrypt password in asp.net 2.0 C#

How Encrypt and discrypt password in asp.net 2.0 C#

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-net
11 Posts 4 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.
  • A amit sahu20

    Hi, I want to encrypt a password and insert it into SQL DB and then discrypt it for sending it to user . how could i do it Thanx n regards Amit sahu

    A Offline
    A Offline
    Anand Desai
    wrote on last edited by
    #2

    Hi Amit, There are lots of javascripts available to encrypt/decrypt passwords. They come in combinations for encrypt/decrypt. apply encrypt script when u insert password. and decrypt while u r checking. U can use only incrypting script only and check incrypted version of password directly with database. thus your original decypted password never travells through network and no possibility to be hacked via channel. Just type "Encrypt Password + Javascript" in goole and u will get tons of scripts. u can prepare urself also simple script like replace "D" with ASCII(D) --> ASCII(D) + 25.

    Anand Desai Developer Atharva Infotech

    A 1 Reply Last reply
    0
    • A amit sahu20

      Hi, I want to encrypt a password and insert it into SQL DB and then discrypt it for sending it to user . how could i do it Thanx n regards Amit sahu

      N Offline
      N Offline
      nyeboy
      wrote on last edited by
      #3

      There is a method to encrypt a password,but it can't discrypt. string pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(tbPass.Text, "MD5"); If you want to find pass,you can reset pass when user have answered your question rightly.

      studing is processing in this life.

      A 1 Reply Last reply
      0
      • A Anand Desai

        Hi Amit, There are lots of javascripts available to encrypt/decrypt passwords. They come in combinations for encrypt/decrypt. apply encrypt script when u insert password. and decrypt while u r checking. U can use only incrypting script only and check incrypted version of password directly with database. thus your original decypted password never travells through network and no possibility to be hacked via channel. Just type "Encrypt Password + Javascript" in goole and u will get tons of scripts. u can prepare urself also simple script like replace "D" with ASCII(D) --> ASCII(D) + 25.

        Anand Desai Developer Atharva Infotech

        A Offline
        A Offline
        Anand Desai
        wrote on last edited by
        #4

        hi Amit, Forgot to tell one thing more. IF u use javascript for that , dont write JS function inline with HTML... because then ur script will be exposed to client machine. Instead of that write JS function in separate Javascript ffile and include that file in ur html.

        Anand Desai Developer Atharva Infotech

        A 1 Reply Last reply
        0
        • N nyeboy

          There is a method to encrypt a password,but it can't discrypt. string pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(tbPass.Text, "MD5"); If you want to find pass,you can reset pass when user have answered your question rightly.

          studing is processing in this life.

          A Offline
          A Offline
          amit sahu20
          wrote on last edited by
          #5

          thanx nyeying But i have already use this FormsAuthentication.HashPasswordForStoringInConfigFile() method in my code now the problem here is on forget password . i have to send it to user mail it, but i can't able to discrypt it

          G N 2 Replies Last reply
          0
          • A Anand Desai

            hi Amit, Forgot to tell one thing more. IF u use javascript for that , dont write JS function inline with HTML... because then ur script will be exposed to client machine. Instead of that write JS function in separate Javascript ffile and include that file in ur html.

            Anand Desai Developer Atharva Infotech

            A Offline
            A Offline
            amit sahu20
            wrote on last edited by
            #6

            thanx anand a js file can also be get by just write the url by getting the name of js file from source view of html page. Is there is no such C# code that will help me

            A 1 Reply Last reply
            0
            • A amit sahu20

              thanx anand a js file can also be get by just write the url by getting the name of js file from source view of html page. Is there is no such C# code that will help me

              A Offline
              A Offline
              Anand Desai
              wrote on last edited by
              #7

              U can set the acces parameter anyways.. or if u doubt this way.. then u can crate your own method and steps in cs file also. just like first add any number in ASCII code of character then subtract any fix number then add/multiply/divide or anything.. I advice u to create your own steps and do exactly reverse steps to decryt. That would be simplest and best for u.

              Anand Desai Developer Atharva Infotech

              A 1 Reply Last reply
              0
              • A Anand Desai

                U can set the acces parameter anyways.. or if u doubt this way.. then u can crate your own method and steps in cs file also. just like first add any number in ASCII code of character then subtract any fix number then add/multiply/divide or anything.. I advice u to create your own steps and do exactly reverse steps to decryt. That would be simplest and best for u.

                Anand Desai Developer Atharva Infotech

                A Offline
                A Offline
                amit sahu20
                wrote on last edited by
                #8

                thanx once again ............ for helping me and interest.. i'll try it and yes its a good way

                G 1 Reply Last reply
                0
                • A amit sahu20

                  thanx nyeying But i have already use this FormsAuthentication.HashPasswordForStoringInConfigFile() method in my code now the problem here is on forget password . i have to send it to user mail it, but i can't able to discrypt it

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #9

                  The purpose of hashing the password is that noone can read it. The price that you pay is that you can't read it yourself, so if the user has lost the password, you have to set a new password. If you want to be able to read the password, you can use encryption instead of hashing. Look in the System.Security.Cryptography namespace.

                  Despite everything, the person most likely to be fooling you next is yourself.

                  1 Reply Last reply
                  0
                  • A amit sahu20

                    thanx once again ............ for helping me and interest.. i'll try it and yes its a good way

                    G Offline
                    G Offline
                    Guffa
                    wrote on last edited by
                    #10

                    Note that this is not encryption, it's only scrambling. An encrypted password is hard to crack, a scrambled password is not. Also, any solution involving Javascript is totally unsafe. Any Javascript that the browser uses can easily be viewed and debugged using well-known tools like FireBug. Internet Explorer 8 will come with a similar tool built in.

                    Despite everything, the person most likely to be fooling you next is yourself.

                    1 Reply Last reply
                    0
                    • A amit sahu20

                      thanx nyeying But i have already use this FormsAuthentication.HashPasswordForStoringInConfigFile() method in my code now the problem here is on forget password . i have to send it to user mail it, but i can't able to discrypt it

                      N Offline
                      N Offline
                      nyeboy
                      wrote on last edited by
                      #11

                      "MD5" only can encrypt,but discrypt.If you want to find old password,it is impossible.The only method is set a new password,then you send it to user's email.

                      studing is processing in this life.

                      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