Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8952703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:55:57+00:00 2026-06-15T13:55:57+00:00

I’m using AESCryptoServiceProvider class. I’m trying to test different CipherMode values. When using OFB

  • 0

I’m using AESCryptoServiceProviderclass. I’m trying to test different CipherMode values.

When using OFBmode I get an exception: Invalid algorithm specified.

In the documentation the mode is documented:

AESCryptoServiceProvider Class
http://msdn.microsoft.com/es-es/library/system.security.cryptography.aescryptoserviceprovider.aspx

CipherMode http://msdn.microsoft.com/es-es/library/system.security.cryptography.ciphermode.aspx

I also have read this similar post, but found no answer:

Does .NET support of AES OFB

My code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Security.Cryptography;
using System.IO;

namespace V_ModosDeEncadenamiento
{
    class Program
    {
        static void Main(string[] args)
        {
            //Clave de 128
            byte[] claveAES128Bits = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                                       0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };


            //Vector de inicialización
            byte[] vectorInicializacion = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
                                            0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF };

            //Texto plano de prueba para codificar. Bloque de 16 bytes todos iguales
            byte[] textoPlanoBloques16BytesIguales = 
                                       {0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                                       0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
                                       0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                                       0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
                                       0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,
                                       0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF};


            //Nombre del fichero en disco con texto cifrado
            String nombreFicheroECB = "zz_TextoCifradoECB.bin";
            String nombreFicheroCBC = "zz_TextoCifradoCBC.bin";
            String nombreFicheroCFB = "zz_TextoCifradoCFB.bin";
            String nombreFicheroOFB = "zz_TextoCifradoOFB.bin";

            //Array con el texto descifrado
            byte[] textoDescifrado = new byte[textoPlanoBloques16BytesIguales.Length];

            AesCryptoServiceProvider aesCrypto = new AesCryptoServiceProvider();
            FileStream fileWrite;
            FileStream fileRead;
            ICryptoTransform encryptor;
            ICryptoTransform decryptor;
            CryptoStream stream;
            CryptoStream streamOut;



            //Establecer valores 
            aesCrypto.KeySize = 128;
            aesCrypto.Key = claveAES128Bits;
            aesCrypto.IV = vectorInicializacion;
            aesCrypto.Padding = PaddingMode.PKCS7;

   aesCrypto.Mode = CipherMode.OFB;
    fileWrite = new FileStream(nombreFicheroOFB, FileMode.Create, FileAccess.Write, FileShare.None);
    encryptor = aesCrypto.CreateEncryptor();
    stream = new CryptoStream(fileWrite, encryptor, CryptoStreamMode.Write);

    // THE EXCEPTION HAPPENS HERE **************************************************
    //******************************************************************************
    stream.Write(textoPlanoBloques16BytesIguales, 0, textoPlanoBloques16BytesIguales.Length);
    stream.Flush();
    stream.Close();
    stream.Dispose();
    fileWrite.Close();

    fileRead = new FileStream(nombreFicheroOFB, FileMode.Open, FileAccess.Read, FileShare.None);
    decryptor = aesCrypto.CreateDecryptor();
    streamOut = new CryptoStream(fileRead, decryptor, CryptoStreamMode.Read);
    streamOut.Read(textoDescifrado, 0, textoDescifrado.Length);
    streamOut.Flush();
    streamOut.Close();
    streamOut.Dispose();
    fileRead.Close();

    //Mostrar datos descifrados
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine("Cifrado modo EFB.");
    Console.WriteLine("Datos descifrados:");
    for (int i = 0; i <= textoDescifrado.Length - 1; i++)
    {
        if (((i % 8) == 0) && (i != 0)) Console.WriteLine(); //8 bytes en cada linea
        Console.Write(" {0:X2}", textoDescifrado[i]);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:55:58+00:00Added an answer on June 15, 2026 at 1:55 pm

    Check this article: http://social.msdn.microsoft.com/Forums/is/netfxbcl/thread/891955cd-3125-487c-9746-9fd07f24b12f

    RijndaelManaged doesn’t support OFB mode at the moment.
    You can code (almost easily) OFB mode yourself, atop of ECB mode, or use side cryptography libraries, like BouncyCastle, SecureBlackbox, whatever else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.