Click here to Skip to main content
16,006,845 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionDynamic properties from Com Interop Pin
Bob Jiang30-Jul-12 5:04
Bob Jiang30-Jul-12 5:04 
AnswerRe: Dynamic properties from Com Interop Pin
Abhinav S30-Jul-12 6:19
Abhinav S30-Jul-12 6:19 
AnswerRe: Dynamic properties from Com Interop Pin
Pete O'Hanlon31-Jul-12 5:08
mvePete O'Hanlon31-Jul-12 5:08 
GeneralRe: Dynamic properties from Com Interop Pin
Bob Jiang31-Jul-12 5:29
Bob Jiang31-Jul-12 5:29 
GeneralRe: Dynamic properties from Com Interop Pin
Pete O'Hanlon31-Jul-12 5:32
mvePete O'Hanlon31-Jul-12 5:32 
QuestionRijndaelManaged Padding is invalid and cannot be removed Pin
Member 906777730-Jul-12 3:28
Member 906777730-Jul-12 3:28 
AnswerRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak31-Jul-12 4:35
mveDave Kreskowiak31-Jul-12 4:35 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 0:02
Member 90677771-Aug-12 0:02 
Yes, i know. But unfortunately i'm sure that the problem is the "#" character that the function use to pad the strings.

In fact, take a look to the encrypt function...

C#
public static string Encrypt(string strInputString, string strKeyString, string myIV)
    {
        if ((strInputString == null) || (strInputString.Length == 0))
        {
            return strInputString;
        }           
            int num4;
            int keySize = 0x100;
            int blockSize = 0x100;
            int length = keySize / 0x10;
            if (strKeyString.Length > length)
            {
                strKeyString = strKeyString.Substring(0, length);
            }
            if (strKeyString.Length < length)
            {
                strKeyString = strKeyString.PadRight(length, '#');
            }
            Encoding.Unicode.GetBytes(strKeyString);
            if (myIV.Length > length)
            {
                myIV = myIV.Substring(0, length);
            }
            if (myIV.Length < length)
            {
                myIV = myIV.PadRight(length, '#');
            }
            Encoding.Unicode.GetBytes(myIV);
            byte[] bytes = Encoding.Unicode.GetBytes(strKeyString);
            byte[] rgbIV = Encoding.Unicode.GetBytes(myIV);
            string str = "";
            RijndaelManaged managed = new RijndaelManaged
            {
                BlockSize = blockSize,
                KeySize = keySize
            };
            MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(strInputString));
            MemoryStream stream2 = new MemoryStream();
            CryptoStream stream3 = new CryptoStream(stream2, managed.CreateEncryptor(bytes, rgbIV), CryptoStreamMode.Write);
            while ((num4 = stream.ReadByte()) != -1)
            {
                stream3.WriteByte((byte)num4);
            }
            stream3.Close();
            stream2.Close();
            stream.Close();
            foreach (byte num5 in stream2.ToArray())
            {
                str = str + num5.ToString("X2");
            }
            return str;

    }


It's perfectly specular to the decrypt function. If the key length >= 16, it's all ok, it doesn't get padded and the algorithm is ok. If the key length < 16, it gets padded with "#", and shows the exception.

I don't understand how VS could interpret a "#" in its textbox in a different way i want.
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Pete O'Hanlon1-Aug-12 2:18
mvePete O'Hanlon1-Aug-12 2:18 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 3:53
Member 90677771-Aug-12 3:53 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Pete O'Hanlon1-Aug-12 4:46
mvePete O'Hanlon1-Aug-12 4:46 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 5:40
Member 90677771-Aug-12 5:40 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak1-Aug-12 4:45
mveDave Kreskowiak1-Aug-12 4:45 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 5:36
Member 90677771-Aug-12 5:36 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak1-Aug-12 6:46
mveDave Kreskowiak1-Aug-12 6:46 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 7:10
Member 90677771-Aug-12 7:10 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak1-Aug-12 7:16
mveDave Kreskowiak1-Aug-12 7:16 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak1-Aug-12 7:08
mveDave Kreskowiak1-Aug-12 7:08 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Member 90677771-Aug-12 10:23
Member 90677771-Aug-12 10:23 
GeneralRe: RijndaelManaged Padding is invalid and cannot be removed Pin
Dave Kreskowiak1-Aug-12 12:19
mveDave Kreskowiak1-Aug-12 12:19 
Questionrecommendation for high quality .NET extension library Pin
Southmountain28-Jul-12 10:23
Southmountain28-Jul-12 10:23 
GeneralRe: recommendation for high quality .NET extension library Pin
Ravi Bhavnani28-Jul-12 10:42
professionalRavi Bhavnani28-Jul-12 10:42 
GeneralRe: recommendation for high quality .NET extension library Pin
Southmountain28-Jul-12 10:48
Southmountain28-Jul-12 10:48 
GeneralRe: recommendation for high quality .NET extension library Pin
Ravi Bhavnani28-Jul-12 10:52
professionalRavi Bhavnani28-Jul-12 10:52 
AnswerRe: recommendation for high quality .NET extension library Pin
Paul Conrad28-Jul-12 11:44
professionalPaul Conrad28-Jul-12 11:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.