Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Invalid character in a Base-64 string

Reply
Thread Tools

Invalid character in a Base-64 string

 
 
=?Utf-8?B?SmFtZXM=?=
Guest
Posts: n/a
 
      04-23-2007
I'm trying to encrypt a part of a url as follows:

test.aspx?id=123&check=abc

Basically, I'm using TripleDes encryption to encrypt the id, then include
this as check in the url to prevent tampering. I'm working from some code
from http://www.15seconds.com/Issue/021210.htm

It seems to work fine except a few seem to through up problems as follows:

Invalid character in a Base-64 string

Line 83:
Line 84: 'convert from string to byte array
Line 85: Dim buffer As Byte() = Convert.FromBase64String(value)
Line 86: Dim ms As MemoryStream = New MemoryStream(buffer)
Line 87: Dim cs As CryptoStream = New CryptoStream(ms,
cryptoProvider.CreateDecryptor(KEY_192, IV_192), CryptoStreamMode.Read)


An example ID that throws up a problem is 1026 which gives the check
eIn9iD3i+JE=

I'm guessing it is to do with the + sign, but even when urlencoded it gives
the same error.

I can post more code if needed... but any advice would be great. Is there a
better / more reliable way to encrypt?

Cheers
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      04-24-2007
the + decodes to a space (as spaces are not allowed in a url).
urlencoding leaves it alone. you will need manually convert it to "%2b"
after performing a urlencode.

-- bruce (sqlwork.com)

James wrote:
> I'm trying to encrypt a part of a url as follows:
>
> test.aspx?id=123&check=abc
>
> Basically, I'm using TripleDes encryption to encrypt the id, then include
> this as check in the url to prevent tampering. I'm working from some code
> from http://www.15seconds.com/Issue/021210.htm
>
> It seems to work fine except a few seem to through up problems as follows:
>
> Invalid character in a Base-64 string
>
> Line 83:
> Line 84: 'convert from string to byte array
> Line 85: Dim buffer As Byte() = Convert.FromBase64String(value)
> Line 86: Dim ms As MemoryStream = New MemoryStream(buffer)
> Line 87: Dim cs As CryptoStream = New CryptoStream(ms,
> cryptoProvider.CreateDecryptor(KEY_192, IV_192), CryptoStreamMode.Read)
>
>
> An example ID that throws up a problem is 1026 which gives the check
> eIn9iD3i+JE=
>
> I'm guessing it is to do with the + sign, but even when urlencoded it gives
> the same error.
>
> I can post more code if needed... but any advice would be great. Is there a
> better / more reliable way to encrypt?
>
> Cheers

 
Reply With Quote
 
 
 
 
=?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=
Guest
Posts: n/a
 
      04-24-2007
bruce barker wrote:
> the + decodes to a space (as spaces are not allowed in a url).
> urlencoding leaves it alone. you will need manually convert it to "%2b"
> after performing a urlencode.
>
> -- bruce (sqlwork.com)
>


I tested this to be really sure, and it works exactly as I though it
would. Using UrlEncode on a string containing a + does encode it into
%2b. There is no need to do it manually.

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert string with control character in caret notation to realcontrol character string. Bart Vandewoestyne C Programming 8 09-25-2012 12:41 PM
invalid character in base-64 string and invalid postback or callba kevin ASP .Net 0 01-16-2008 09:39 PM
Invalid URI: There is an invalid sequence in the string. Error!! Patrick.O.Ige ASP .Net 1 07-02-2006 11:21 AM
8 bit character string to 16 bit character string Brand Bogard C Programming 8 05-28-2006 05:05 PM
Character reference "&#c" is an invalid XML character cgbusch XML 6 09-02-2003 07:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57