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 to decrypt a password

How to decrypt a password

Scheduled Pinned Locked Moved ASP.NET
algorithmscryptographyhelptutorial
7 Posts 4 Posters 2 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
    janani13
    wrote on last edited by
    #1

    Hai all, I'm encrypting the password by using the code as below . Please tell me how to decrypt the same.Please help me..

    #region Password Util
    /// <summary>
    /// Encrypts a string using the SHA256 algorithm.
    /// </summary>
    public static string HashPassword(string plainMessage)
    {
    byte[] data = Encoding.UTF8.GetBytes(plainMessage);
    using (HashAlgorithm sha = new SHA256Managed())
    {
    byte[] encryptedBytes = sha.TransformFinalBlock(data, 0, data.Length);
    return Convert.ToBase64String(sha.Hash);
    }

    }
    
    
    #endregion
    
    protected void btnSubmit\_Click(object sender, EventArgs e)
    {
        bo.UserID = txtUserId.Text;
        Password p = new Password(txtPassword.Text.ToString());
        String newpwd = p.SaltedPassword;
        System.Nullable<int> newsaltkey = p.Salt;
        bo.Encryptpwd = newpwd;
        bo.Saltkey = p.Salt;
        bo.Password = txtPassword.Text;
    
        passwordFormat = MembershipPasswordFormat.Hashed;
        if (passwordFormat == MembershipPasswordFormat.Hashed)
            bo.Blogpwd = HashPassword(txtPassword.Text);
        else
            bo.Blogpwd = txtPassword.Text;
    
    B H 2 Replies Last reply
    0
    • J janani13

      Hai all, I'm encrypting the password by using the code as below . Please tell me how to decrypt the same.Please help me..

      #region Password Util
      /// <summary>
      /// Encrypts a string using the SHA256 algorithm.
      /// </summary>
      public static string HashPassword(string plainMessage)
      {
      byte[] data = Encoding.UTF8.GetBytes(plainMessage);
      using (HashAlgorithm sha = new SHA256Managed())
      {
      byte[] encryptedBytes = sha.TransformFinalBlock(data, 0, data.Length);
      return Convert.ToBase64String(sha.Hash);
      }

      }
      
      
      #endregion
      
      protected void btnSubmit\_Click(object sender, EventArgs e)
      {
          bo.UserID = txtUserId.Text;
          Password p = new Password(txtPassword.Text.ToString());
          String newpwd = p.SaltedPassword;
          System.Nullable<int> newsaltkey = p.Salt;
          bo.Encryptpwd = newpwd;
          bo.Saltkey = p.Salt;
          bo.Password = txtPassword.Text;
      
          passwordFormat = MembershipPasswordFormat.Hashed;
          if (passwordFormat == MembershipPasswordFormat.Hashed)
              bo.Blogpwd = HashPassword(txtPassword.Text);
          else
              bo.Blogpwd = txtPassword.Text;
      
      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Hash Algorithm are one way encryption.You can not decrypt what you can do,you can encrypt the text and then match with the encrypted one.If you require to decrypt the data then you can use other algorithms...

      Cheers!! Brij Check My Latest Article

      J 1 Reply Last reply
      0
      • J janani13

        Hai all, I'm encrypting the password by using the code as below . Please tell me how to decrypt the same.Please help me..

        #region Password Util
        /// <summary>
        /// Encrypts a string using the SHA256 algorithm.
        /// </summary>
        public static string HashPassword(string plainMessage)
        {
        byte[] data = Encoding.UTF8.GetBytes(plainMessage);
        using (HashAlgorithm sha = new SHA256Managed())
        {
        byte[] encryptedBytes = sha.TransformFinalBlock(data, 0, data.Length);
        return Convert.ToBase64String(sha.Hash);
        }

        }
        
        
        #endregion
        
        protected void btnSubmit\_Click(object sender, EventArgs e)
        {
            bo.UserID = txtUserId.Text;
            Password p = new Password(txtPassword.Text.ToString());
            String newpwd = p.SaltedPassword;
            System.Nullable<int> newsaltkey = p.Salt;
            bo.Encryptpwd = newpwd;
            bo.Saltkey = p.Salt;
            bo.Password = txtPassword.Text;
        
            passwordFormat = MembershipPasswordFormat.Hashed;
            if (passwordFormat == MembershipPasswordFormat.Hashed)
                bo.Blogpwd = HashPassword(txtPassword.Text);
            else
                bo.Blogpwd = txtPassword.Text;
        
        H Offline
        H Offline
        himanshu2561
        wrote on last edited by
        #3

        Hi, You have asked this question so many times............:mad: Answer is same HASH IS ONE WAY ENCRYPTION

        himanshu

        J 1 Reply Last reply
        0
        • B Brij

          Hash Algorithm are one way encryption.You can not decrypt what you can do,you can encrypt the text and then match with the encrypted one.If you require to decrypt the data then you can use other algorithms...

          Cheers!! Brij Check My Latest Article

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

          But i'm not getting the input password from user.ok let me look at some other option.

          1 Reply Last reply
          0
          • H himanshu2561

            Hi, You have asked this question so many times............:mad: Answer is same HASH IS ONE WAY ENCRYPTION

            himanshu

            J Offline
            J Offline
            janani13
            wrote on last edited by
            #5

            I havn't ask some many times.This is second time.First time i didnt get the expected answer.Thats y i post the same message again.Got it..

            K 1 Reply Last reply
            0
            • J janani13

              I havn't ask some many times.This is second time.First time i didnt get the expected answer.Thats y i post the same message again.Got it..

              K Offline
              K Offline
              K0306
              wrote on last edited by
              #6

              Try this for Encrypt and Decrypt Encrypt and Decrypt Data with C#[^]

              Regards, Karthik K...

              J 1 Reply Last reply
              0
              • K K0306

                Try this for Encrypt and Decrypt Encrypt and Decrypt Data with C#[^]

                Regards, Karthik K...

                J Offline
                J Offline
                janani13
                wrote on last edited by
                #7

                Thx Karthik.. I'll Check it out..

                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