.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Invalid length for a Base-64 char array - how do I check the length?????

Posted By:      Posted Date: October 02, 2010    Points: 0   Category :ASP.Net

Invalid length for a Base-64 char array

I am encrypting and decrypting my querystring. I need a way of checking the querystrings length before I decrypt it. When I mess with the querystring, shorten it for example, my decryption method fails. Can somebody help me with the if statement please to check the length of the urlDecode string??????

public static string Decrypt(string inputText)      {          if (!String.IsNullOrEmpty(inputText))

View Complete Post

More Related Resource Links

Invalid length for a Base-64 char array for my coding in ASP.net C#. How to solve it ?


Hi Friends ,

I have done encrypted password and decode but i got error  like  this  " Invalid length for a Base-64 char array" .

Pls help . Thanks


psswd = txtPassword.Text;

pwed = base64Decode(psswd);

public string base64Decode(string sData)
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(sData);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            char[] decoded_char = new char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
            string result = new String(decoded_char); return result;

How to Pass higher Length of Byte Array to the remoting method

Dear all,I am using a windows application and the businness logic is present in the remote server.Once particular method takes bytearray as input parameter...Whenever the method call is made the function returns value .This is limited for the particular bytearray length. (4109228 bytes).If the length of bytearray crosses 4109228 bytes.I am getting an error that "input stream is not valid binary format".How to Pass higher Length of Byte Array to the remoting method... Greater than 4 MB?I believe something is missing in web.config or app.config...?What could be the issue...? Any sugesstions are welcome....ThanksRavikumar

fixed length array in CodeTypeReference?

I am trying to generate a fixed length array: e.g.: private object[5] _values;   I can generate member fine without the size but would prefer to have the length set at generation time.

how to check the length of a string value in jquery?



I want to modify my userAvailabilityCheck code and want to add the code that this userAvailabilityCheck function does not fire If the textbox is null or having character less than 6 but display related error message.

Below is my code-

 var $j = jQuery.noConflict(); //set no conflict so you can use with MS AJAX.
        $j(document).ready(function() {
            // Find the ClientID of your TextBox UserName inside Create User Wizard
        var UserNameClientID = '<%= UserName.ClientID %>';
            // Make the AJAX call to the WebMethod when the textbox loses focus
            $j("#" + UserNameClientID).blur(function() {
             var userName = $j("#" + '<%= UserName.ClientID %>').val();

            if ($('#UserName').is(':empty'))
                $('#username-availability').html("<label>Username can't be empty!</label>");
            else if (userName.length() <= 6)
                $('#username-availability').html(" <label>Username must be at least 6 characters!</label>");
                        type: "POST",
                        url: "Register.aspx/Ch

What would make array.length return an incorrect number?


[sub-titled: array.length is working correctly, but Nick has almost certainly done something stupid.] 

This is probably obvious, but has got me mystified.  I have an array which is being created like this:

var TempPoints = $get('<%=PointList.ClientID%>').value;
PointsList = eval(TempPoints);

The field coming in from the server is formatted like this:

[[1,2], [3,4], [5,6], ......... [99, 100]]

So, after the eval has done its work, PointsList is an array of objects, each of which is an array containing two numbers.  If I then do a PointsList.length, I would expect to see the number of elements in the array.  I then of course need to remember that the array is zero based and that the last element is (PointsList.length - 1).  Well, so I would have thought!

In fact, the length seems to be reporting one more than it should, so the last element is actually (PointsList.length - 2).

That is borne out by what I can see in the Visual Studio debugger:

Visual Studio Screenshot

As you can see there, the array has elements 0 through 138 - but the length is reported as 140.

What am I missing?



Length of the data to decrypt is invalid. tripleDES c#


Hey there.. i am trying to make an Encrypt and Decrypt method...

When i try to encrypt it goes fine.. but when i right after try to decrypt it i get an:

"Length of the data to decrypt is invalid" error...

the error occours when i try to run the code FlushFinalBlock();

here is my code:

        public string Encrypt(string plainText)
            UTF8Encoding utf8Encoder = new UTF8Encoding();
            byte[] inputInBytes = utf8Encoder.GetBytes(plainText);
            TripleDESCryptoServiceProvider tdesProvider = new TripleDESCryptoServiceProvider();
            ICryptoTransform cryptoTransform = tdesProvider.CreateEncryptor(symKey, IVKey);
            MemoryStream encryptedStream = new MemoryStream();
            CryptoStream cryptStream = new CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write);

            cryptStream.Write(inputInBytes, 0, inputInBytes.Length);
            encryptedStream.Position = 0;
            byte[] result = new byte[encryptedStream.Length];
            encryptedStream.Read(result, 0, (int)encryptedStream.Length);
            return utf8Encoder.GetString(result);

        public string Decrypt(string encryptedString)
            UTF8Encoding utf8Encoder =

Length of array element


This is a Visual C++, CLR, Windows Forms Application. Visual Studio 2008.

I have a string array;  array<String^>^MY_ARRAY = {element1, element-2, element-3, etc};

How do I find the length of each element?

Invalid length parameter passed to the SUBSTRING function


Hi all,

I am having a weird issue after we upgraded our DB server to SQL 2005.

I have a SP used to extract exchange rate, and a job calls this SP daily. This job worked fine on SQL 2000, and works very well in Management studio if I call this SP seperately, but failed in sql job in 2005.

The error statement pointed to:

select left(@row, charindex(',', @row)-1),  REVERSE(left(@reversedrow, charindex(',', @reversedrow)-1))

The error message is:

Invalid length parameter passed to the SUBSTRING function.

Anyone knows what's the difference for LEFT function between sql 2000 and 2005?


The maximum array length quota (16384) has been exceeded while reading XML data.



I am getting this error when I try to send a message to my service. I have updated the ReaderQuotas on both the client and the server. Is there something else that I need to do to get the service to accept the message?



Web Q&A: Storing SQL Data, URL Query Length, and More


Find out the best way to store large amounts of XML data in SQL Server, along with the performance implications. What's the maximum length of an XML query to SQL Server in a URL?

Edited by Nancy Michell

MSDN Magazine May 2003

Process.Start - arguments length restriction to 2080 characters

Hi, I'm wondering why is there a limit to "The sum of the length of the arguments and the length of the full path to the process " to 2080? I see that the documentation says that a Win32Exception is thrown if this exceeds 2080 characters. Can someone please explain to me this limit? I'm trying to start a process and I have a lot of arguments to pass, and of course ... I exceed the limit of 2080.   Thanks, Ionut.

Convert Data from TXT file and face a length issue! Need help!

Hi All, I am trying to convert some TXT files in to sqlserver database by using SSIS.  The problem I am facing right now is that some TXT files I have are fixed with line length 286.  However, for the some other TXTs they have 296 characters per line. The reason why this happened is some one added one more field before generating those TXTs.  Instead of creating two SSIS packages for converting those TXTs, can I find another way to get around this?   

How to set minimum length of chars ina text box

I have a textbox1, want to set a minimum length of atleast 8 chars, how to do the min length validation. Thank you for thhe helpful info. 

Cleanest way of setting max string length for text in GridView cells?

I want to make sure that each row in the table is the height of one line of text only.  I know you can set RowStyle-Wrap="false", but I also don't want any really wide rows.  I know I can go through each cell on RowDataBound or something and cut it to a particular length and then append an ellipsis on the end, but is there a neater way of doing the same thing?

The maximum string content length quota (8192) has been exceeded while reading XML data.

Hi, I have been working on implementing a WCF service and have run into this problem with the maxStringContentLength.  I have read a bunch of posts here on how to correct it and none of them have worked.  I have updated my web.config in my local IIS5 published service to be maxStringContentLength="2147483647" and have updated my application's app.config to be maxStringContentLength="2147483647".  I delete all DLL's, rebuild, restart IIS, make sure all VS 2008 virtual webs are stopped, republish multiple times...even reboot my machine and I continually receive the following error message:The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/qlStatement. The InnerException message was 'There was an error deserializing the object of type System.String. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 171, position 35.'.  Please see InnerException for more details.I am running the service on my local machine: Win XP SP2, IIS5, .Net 3.5, VS 2008Here is my WCF service's servicemodel section of the web.config:    <system.serviceModel>    <bindings>      <wsHt

Is there a limit to the length of a vb script job

This sounds stupid, but I created a ms sql server job that is activeX - language = vbscript The job is just a series of log statements. If I make the script > 300 lines long, I get errors. If I chop out some of the log statements, it works ok. Does anyone have any idea what is going on and how to get around / fix this? thanks jonathan

Scalar Function Variable length return value

Would like to write a Scalar Function that returns a variable length string of spaces. Length being determined by an input parameter (int) Maybe I am missing the obvious but it seems impossible because you have to declare the size  of the varchar return variable I know there is a performance hit using scalar functions but we are generating a view that emulates an old fixed file format with lots of unused fields. So it will make the resultant view readable. So I am looking to do select goodfield1,fnSpace(5) as Unusedfield1,goodfield2,fnSpace(10)... from MyView thanks Bob
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend