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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Encryption [modified]

Encryption [modified]

Scheduled Pinned Locked Moved ASP.NET
helpsecurityquestiondatabaselearning
5 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.
  • A Offline
    A Offline
    alexfromto
    wrote on last edited by
    #1

    Hi. Does anyone has some experience with Encryption? I need to encrypt password user submits and store it in the database. And of course I need to decrypt it back and compare to user password when user signs in. I created a test page and use System.Security.Cryptography.RijndaelManaged. On that page I encrypted string (passwrod) but not sure what to do next. I get Byte() back. How do I store it in the database? But most important how do I decrypt it back? When running encrypt and decrypt on the same page one after another and useing the same key it works with not problem. But if use decrypt separetely it throws me error. Here's the error I get: PKCS7 padding is invalid and cannot be removed. My guess it has something to do with Key and/or IV. Does that mean I need to save Key as well? I'm lost. Please help. Thanks, -- modified at 9:27 Thursday 23rd November, 2006

    B 1 Reply Last reply
    0
    • A alexfromto

      Hi. Does anyone has some experience with Encryption? I need to encrypt password user submits and store it in the database. And of course I need to decrypt it back and compare to user password when user signs in. I created a test page and use System.Security.Cryptography.RijndaelManaged. On that page I encrypted string (passwrod) but not sure what to do next. I get Byte() back. How do I store it in the database? But most important how do I decrypt it back? When running encrypt and decrypt on the same page one after another and useing the same key it works with not problem. But if use decrypt separetely it throws me error. Here's the error I get: PKCS7 padding is invalid and cannot be removed. My guess it has something to do with Key and/or IV. Does that mean I need to save Key as well? I'm lost. Please help. Thanks, -- modified at 9:27 Thursday 23rd November, 2006

      B Offline
      B Offline
      Britney S Morales
      wrote on last edited by
      #2

      I got another solution You must to create a new class sheet (name.CS) Add these libraries using System.Security.Cryptography; using System.Text; using System.IO; using System.Xml; I made these functions based in a codeproject encrypt solution public string EncryptProcess(string password) { string passwordEncryted = Encrypt(password, "&%#@?,:*"); return (passwordEncryted); } private static String Encrypt(String strText, String strEncrKey) { byte[] bKey = new byte[8]; byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; try { bKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0, 8)); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); Byte[] inputByteArray = Encoding.UTF8.GetBytes(strText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(bKey, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); return Convert.ToBase64String(ms.ToArray()); } catch (Exception ex) { return ex.Message; } } You must to invoice the first process Ex: string pass = EncryptProcess("SGC"); //Uppercase the answer is the string "2zhZqCYvfJc=" This is the Encrypt process, write me if works for you.. And i will write the Decrypt process ;P

      keep Learning and you never will be out of date...

      A 1 Reply Last reply
      0
      • B Britney S Morales

        I got another solution You must to create a new class sheet (name.CS) Add these libraries using System.Security.Cryptography; using System.Text; using System.IO; using System.Xml; I made these functions based in a codeproject encrypt solution public string EncryptProcess(string password) { string passwordEncryted = Encrypt(password, "&%#@?,:*"); return (passwordEncryted); } private static String Encrypt(String strText, String strEncrKey) { byte[] bKey = new byte[8]; byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; try { bKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey.Substring(0, 8)); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); Byte[] inputByteArray = Encoding.UTF8.GetBytes(strText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(bKey, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); return Convert.ToBase64String(ms.ToArray()); } catch (Exception ex) { return ex.Message; } } You must to invoice the first process Ex: string pass = EncryptProcess("SGC"); //Uppercase the answer is the string "2zhZqCYvfJc=" This is the Encrypt process, write me if works for you.. And i will write the Decrypt process ;P

        keep Learning and you never will be out of date...

        A Offline
        A Offline
        alexfromto
        wrote on last edited by
        #3

        Thanks a lot. I will try. I do believe I've seen something similar online. Do you had any experience with System.Security.Cryptography.RijndaelManaged? Thank you.

        B 1 Reply Last reply
        0
        • A alexfromto

          Thanks a lot. I will try. I do believe I've seen something similar online. Do you had any experience with System.Security.Cryptography.RijndaelManaged? Thank you.

          B Offline
          B Offline
          Britney S Morales
          wrote on last edited by
          #4

          X| nop

          keep Learning and you never will be out of date...

          A 1 Reply Last reply
          0
          • B Britney S Morales

            X| nop

            keep Learning and you never will be out of date...

            A Offline
            A Offline
            alexfromto
            wrote on last edited by
            #5

            Thanks anyway. I found some answeres and will try to create different ways of doing it.

            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