blob: 5611a831cf8f863babcb44450a1f2391fb5c3c60 (
plain) (
blame)
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
|
using System;
using System.IO;
namespace Org.BouncyCastle.Utilities.Encoders
{
/**
* Convert binary data to and from UrlBase64 encoding. This is identical to
* Base64 encoding, except that the padding character is "." and the other
* non-alphanumeric characters are "-" and "_" instead of "+" and "/".
* <p>
* The purpose of UrlBase64 encoding is to provide a compact encoding of binary
* data that is safe for use as an URL parameter. Base64 encoding does not
* produce encoded values that are safe for use in URLs, since "/" can be
* interpreted as a path delimiter; "+" is the encoded form of a space; and
* "=" is used to separate a name from the corresponding value in an URL
* parameter.
* </p>
*/
public class UrlBase64Encoder
: Base64Encoder
{
public UrlBase64Encoder()
{
encodingTable[encodingTable.Length - 2] = (byte) '-';
encodingTable[encodingTable.Length - 1] = (byte) '_';
padding = (byte) '.';
// we must re-create the decoding table with the new encoded values.
InitialiseDecodingTable();
}
}
}
|