473,651 Members | 2,994 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 9857
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
6492
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 materials hang on
2
23932
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, Brian
5
3414
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 provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
12
4034
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 exists but I knew that I might have trouble if I tried to check the value of the input without first...
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 sharing the source app's cookie is a .NET 1.1 app. <machineKey...
2
9155
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
9948
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
3173
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
3077
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
2531
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 insensitive Lowercase only I have created a user system and I can login in the system, however, when
0
8361
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 usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8466
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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

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.