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. [CLOSED] Aes Encryption fails

[CLOSED] Aes Encryption fails

Scheduled Pinned Locked Moved ASP.NET
algorithmssecurityhelpquestion
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.
  • V Offline
    V Offline
    vishalgpt
    wrote on last edited by
    #1

    why does this function fails, with CipherMode.OFB where as it works with CipherMode.ECB

    Public Function EncryptAES(sIn As String, sKey As String) As String
    Dim AES As New RijndaelManaged()
    Dim ahashMD5 As New MD5CryptoServiceProvider()
    AES.Key = ahashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
    AES.Mode = CipherMode.OFB
    Dim AESEncrypt As ICryptoTransform = AES.CreateEncryptor()
    Dim aBuffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
    Return Convert.ToBase64String(AESEncrypt.TransformFinalBlock(aBuffer, 0, aBuffer.Length))
    End Function

    Error Message : Specified cipher mode is not valid for this algorithm.

    Regards, Vishal

    Richard DeemingR 1 Reply Last reply
    0
    • V vishalgpt

      why does this function fails, with CipherMode.OFB where as it works with CipherMode.ECB

      Public Function EncryptAES(sIn As String, sKey As String) As String
      Dim AES As New RijndaelManaged()
      Dim ahashMD5 As New MD5CryptoServiceProvider()
      AES.Key = ahashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(sKey))
      AES.Mode = CipherMode.OFB
      Dim AESEncrypt As ICryptoTransform = AES.CreateEncryptor()
      Dim aBuffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
      Return Convert.ToBase64String(AESEncrypt.TransformFinalBlock(aBuffer, 0, aBuffer.Length))
      End Function

      Error Message : Specified cipher mode is not valid for this algorithm.

      Regards, Vishal

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Because the RijndaelManaged class doesn't support the OFB cipher mode. It only supports CBC, ECB and CFB.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      V 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Because the RijndaelManaged class doesn't support the OFB cipher mode. It only supports CBC, ECB and CFB.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        V Offline
        V Offline
        vishalgpt
        wrote on last edited by
        #3

        sir can you please guide which aes module for asp.net contains OFB cipher mode

        Regards, Vishal

        Richard DeemingR 1 Reply Last reply
        0
        • V vishalgpt

          sir can you please guide which aes module for asp.net contains OFB cipher mode

          Regards, Vishal

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          There doesn't appear to be anything built-in to .NET which supports using AES in OFB mode. You'll need to find a third-party library to support that.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          V 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            There doesn't appear to be anything built-in to .NET which supports using AES in OFB mode. You'll need to find a third-party library to support that.


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            V Offline
            V Offline
            vishalgpt
            wrote on last edited by
            #5

            Thank you

            Regards, Vishal

            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