Base64问题 [英] Base64 question

查看:95
本文介绍了Base64问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要附加一个简短的密文字符串作为编码的查询变量,因此

它对URL有效。加密后,我将字节转换为Base64。

但是,结果包括对URL无效的字符,特别是

''+''符号。所以,我必须通过

HttpUtility.UrlEncode()循环输出字符串。这需要时间。我在C#中编写了自己的URL安全Base64

转换器,这就像我能做到的那样精益求精。它比提供的要慢得多(b)b(约6倍)。但是,它使用标准Base64转换器所需的时间约为70%的

,然后通过UrlEncode()跳转



我正在使用.Net 2.0,我还没有找到一种方法来强制使用内置的

Base64转换器来使用可以避免旅行的字符集

UrlEncode。我错过了什么吗?如果没有,有没有办法在未来版本中添加这个

功能?


谢谢,


Jim Brandley

I need to append a short ciphertext string as a query variable encoded so
it''s valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL, notably
''+'' symbols. So, I have to cycle the output string through
HttpUtility.UrlEncode(). That takes time. I wrote my own URL-safe Base64
converter in C#, that''s about as lean as I can make it. It is much slower
(about 6 times) than the the one provided. However, it runs in about 70% of
the time required to use the standard Base64 converter followed by a trip
through UrlEncode().

I am using .Net 2.0, and I have not found a way to coerce the built in
Base64 converter to use a character set that could avoid the trip through
UrlEncode. Am I missing anything? If not, is there any way to add this
capability to a future release?

Thanks,

Jim Brandley

推荐答案

Jim Brandley写道:
Jim Brandley wrote:

我需要附加一个短的密文string作为查询变量编码,因此

它对URL有效。加密后,我将字节转换为Base64。

但是,结果包括对URL无效的字符,特别是

''+''符号。所以,我必须通过

HttpUtility.UrlEncode()循环输出字符串。这需要时间。我在C#中编写了自己的URL安全Base64

转换器,这就像我能做到的那样精益求精。它比提供的要慢得多(b)b(约6倍)。但是,它使用标准Base64转换器所需的时间约为70%的

,然后通过UrlEncode()跳转



我正在使用.Net 2.0,我还没有找到一种方法来强制使用内置的

Base64转换器来使用可以避免旅行的字符集

UrlEncode。我错过了什么吗?如果没有,有没有办法在未来版本中添加这个

功能?
I need to append a short ciphertext string as a query variable encoded so
it''s valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL, notably
''+'' symbols. So, I have to cycle the output string through
HttpUtility.UrlEncode(). That takes time. I wrote my own URL-safe Base64
converter in C#, that''s about as lean as I can make it. It is much slower
(about 6 times) than the the one provided. However, it runs in about 70% of
the time required to use the standard Base64 converter followed by a trip
through UrlEncode().

I am using .Net 2.0, and I have not found a way to coerce the built in
Base64 converter to use a character set that could avoid the trip through
UrlEncode. Am I missing anything? If not, is there any way to add this
capability to a future release?



我发现很难相信URL编码可能会对总体性能造成明显的影响。


Arne

I find it difficult to believe that URL encoding could have a
noticeable impact on total performance.

Arne


根据它所做的秒表课程。


Arne Vajh?j < ar ** @ vajhoej.dkwrote in message

news:46 *********************** @ news.sunsite。 dk ...
According to the Stopwatch class it did.

"Arne Vajh?j" <ar**@vajhoej.dkwrote in message
news:46***********************@news.sunsite.dk...

Jim Brandley写道:
Jim Brandley wrote:

>我需要附加一个短的密文字符串作为一个编码的查询变量,它对URL有效。加密后,我将字节转换为Base64。
但是,结果包括对URL无效的字符,特别是+符号。所以,我必须通过HttpUtility.UrlEncode()循环输出字符串。这需要时间。我在C#中编写了自己的URL安全Base64
转换器,这就像我能做到的那样精简。它比提供的慢得多(约6倍)。但是,它运行的时间大约是使用标准Base64转换器所需时间的70%,然后通过UrlEncode()运行。

我使用的是.Net 2.0,而且我还没有找到一种方法来强制使用内置的Base64转换器来使用可以避免通过UrlEncode跳转的字符集。我错过了什么吗?如果没有,有没有办法在未来版本中添加这个功能?
>I need to append a short ciphertext string as a query variable encoded so
it''s valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL,
notably ''+'' symbols. So, I have to cycle the output string through
HttpUtility.UrlEncode(). That takes time. I wrote my own URL-safe Base64
converter in C#, that''s about as lean as I can make it. It is much slower
(about 6 times) than the the one provided. However, it runs in about 70%
of the time required to use the standard Base64 converter followed by a
trip through UrlEncode().

I am using .Net 2.0, and I have not found a way to coerce the built in
Base64 converter to use a character set that could avoid the trip through
UrlEncode. Am I missing anything? If not, is there any way to add this
capability to a future release?



我发现很难相信URL编码可能会对总体性能产生明显的影响。


Arne


I find it difficult to believe that URL encoding could have a
noticeable impact on total performance.

Arne



Jim,

你可以考虑改用HEX。本文可能会提供一些想法:
http://www.eggheadcafe
- 彼得

网站:
http://www.eggheadcafe.com

UnBlog: http://petesbloggerama.blogspot.com

BlogMetaFinder(测试版): http://www.blogmetafinder.com


" Jim Brandley"写道:
Jim,
You could consider using HEX instead. This article may provide some ideas:
http://www.eggheadcafe.com/articles/20060427.asp

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Jim Brandley" wrote:

我需要附加一个短的密文字符串作为编码的查询变量,这样它对于一个URL是有效的。加密后,我将字节转换为Base64。

但是,结果包括对URL无效的字符,特别是

''+''符号。所以,我必须通过

HttpUtility.UrlEncode()循环输出字符串。这需要时间。我在C#中编写了自己的URL安全Base64

转换器,这就像我能做到的那样精益求精。它比提供的要慢得多(b)b(约6倍)。但是,它使用标准Base64转换器所需的时间约为70%的

,然后通过UrlEncode()跳转



我正在使用.Net 2.0,我还没有找到一种方法来强制使用内置的

Base64转换器来使用可以避免旅行的字符集

UrlEncode。我错过了什么吗?如果没有,有没有办法在未来版本中添加这个

功能?


谢谢,


Jim Brandley
I need to append a short ciphertext string as a query variable encoded so
it''s valid for a URL. After encryption, I convert the bytes to Base64.
However, the result includes characters that are invalid for a URL, notably
''+'' symbols. So, I have to cycle the output string through
HttpUtility.UrlEncode(). That takes time. I wrote my own URL-safe Base64
converter in C#, that''s about as lean as I can make it. It is much slower
(about 6 times) than the the one provided. However, it runs in about 70% of
the time required to use the standard Base64 converter followed by a trip
through UrlEncode().

I am using .Net 2.0, and I have not found a way to coerce the built in
Base64 converter to use a character set that could avoid the trip through
UrlEncode. Am I missing anything? If not, is there any way to add this
capability to a future release?

Thanks,

Jim Brandley


这篇关于Base64问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆