473,574 Members | 3,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invalid length for a Base-64 char array.

26 New Member
Hi all ,


I am using encryption to encrypt the query string passed from one
page to other. In works fine most of the time but occationally i get this error
-

The line that throws that exception is

Dim cipherTextBytes As Byte()

cipherTextBytes = Convert.FromBas e64String(ciphe rText)

The Error name is

Run-time exception thrown : System.FormatEx ception - Invalid length for a
Base-64 char array.

Its Very Urgent .Please anyone help me wat to do

Thanks in advance
Selvamariapan.c
Nov 8 '08 #1
2 9840
joedeene
583 Contributor
Have a look at a similar thread..

with base64, every three bytes (24 bits) of data is converted to four bytes
of printable data (6 bit). when you convert base64 back, you read 4 bytes at
a time and convert back to 3 bytes. you get this error when you don't have a
mulitple of 4. most likely the data is bad, you can append 1 to 3 '='s
to get the correct length (these convert to nulls). you should figure out
why your base64 string are actually invalid.
Basically whatever data you're reading into your byte, it isn't an equal multiple of four, therefore it throws that exception. You can try appending one byte at the end and then test it, if it throws an exception add another byte. You shouldn't have to append more than 3 bytes. And make sure the appended character(s) are something you can tell apart from the rest of them.

joedeene
Nov 8 '08 #2
mldisibio
190 Recognized Expert New Member
Joe is correct, but just to clarify, using the quoted post:

- the Base64 standard already stipulates using "=" as the filler character for the last four bytes (so you shouldn't have to make-up your own filler)

and

- (as the previous post said) the exception indicates an underlying problem that the base64 string (that is, the encrypted string) was somehow incorrectly formed to begin with. The base64 encryption algorithm used should already have added this filler while encrypting.

The only reason I emphasize that, is because although Joe's solution would work to eliminate the exception, I would worry about it masking an underlying encryption problem.

Just two cents.

Mike
Nov 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6488
by: Onder Kaya | last post by:
We have Windows NT 4.0 Oracle 8.1.7 and ORACLE ERP 11.5.8 We created new discrete job. This discrete job contains material requirements and we have custom form which is haz.issue. This form display dj's(discrete job) requirements. Material requirements is being created from this form then materials issue from subinventories. But SOME...
2
23927
by: Brian Genisio | last post by:
What is the most reliable way to grab the URL base for a document? I can get window.location.protocol + window.location.host + window.location.path... and that would work most the time, but if the <BASE> tag is used, the URL base changes to that tag. Is there a one-stop-shop location to retreive the URL base of the document? Thanks,...
5
3407
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to...
12
4029
by: bcr07548 | last post by:
I am writing a web site that uses JavaScript to validate certain forms and I seem to be having some trouble. The site uses PHP and for one of the forms, depending on the situation, one of of the text inputs does not exist - the PHP doesn't generate the HTML for it. I wanted to have the validation script check the length of the input if it...
0
676
by: dba123 | last post by:
I am getting the following error when a sub domain is receiving a shared cookie: I have this in both web.config of each application. The 1.1 application does not have the decryption= value because you cannot have that for 1.1 or asp.net will error out. The source application is coded in .NET 2.0 but the target application that's...
2
9153
by: ansonee | last post by:
I have the follwoing stored procedure: ALTER procedure .( @ExecutionGUID int = null ) as begin set nocount on declare @s varchar(500) declare @i int
2
9946
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
1
3165
by: banagani | last post by:
Hi All, I am facing an issue in the XmlTextWriter class in the dotnet 2.0. This is the sample code Actual XML is like this <Name>&#x8A73;&#x7D30;&#x4ED5;&#x69D8;&#x306B;</Name>
3
3073
by: =?Utf-8?B?Vmlub2Q=?= | last post by:
Hi All, I am facing an issue in the XmlTextWriter class in the dotnet 2.0. This is the sample code Actual XML is like this <Name>詳細仕様に</Name>
0
2528
by: parun | last post by:
Hello, is there a possibility to log on to a user whose length is greater than 8 characters. My system is AIX and system base authentication . At IBM I found this information: Limit Windows Linux / UNIX Group Name Length Up to 30 characters Up to 30 characters User Name Length Up to 30 characters (1) (2) Up to 8 characters Case Case...
0
7821
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
8083
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8258
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7835
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5326
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2255
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1360
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1087
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.