C# Class FiftyOne.Foundation.Bases.Base32

Contains methods to convert data into Base32 strings.

Many mobile devices contain defects that subtly change strings used as query string parameters or as hidden fields. Encoding strings using Base32 ensures the string can always be read back during subsequent requests. For example a Base64 encoded string will use upper and lower case letters. A Base32 encoded strings uses upper case letters and numbers only ensuring any mobile device that converts query string parameters to lower case do not alter the encoded contents.

The Base32 encoding used in this implementation removes commonly mistyped charaters such as the number 0 (zero) and the letter O. This means less mistakes will be made if someone copies out the URL including query string parameters.

We suggest you keep the amount of information stored in query string parameters and hidden fields to a minimum to ensure the lowest possible page weight. Hold information in the session store or a persitent database that supports stateless operation of your application and store a unique reference in hidden fields or query string parameters encoded using Base32.
Exibir arquivo Open project: 51Degrees/dotNET-Device-Detection

Public Methods

Method Description
Decode ( string value ) : byte[]

Takes a string previously generate with the Encode method and returns the original byte array.

DecodeToInteger ( string value ) : int

Takes a string previously generate with the Encode method and returns the original integer value.

DecodeToShortArray ( string value ) : short[]

Takes a string previously generate with the Encode method and returns the original short array value.

DecodeToString ( string value ) : string

Takes a string previously generate with the Encode method and returns the original string value.

Encode ( byte bytes ) : string

Encodes a byte array as a Base32 encoded string.

The following code will encrypt the string "Hello World" and store the result as a Base32 encoded string in the variable secure.

string secure = Mobile.Base32.Encode( Mobile.Crypto.Encrypt("Hello World"));

secure can be decoded using the following code.

string plain = Mobile.Crypto.Decrypt( Mobile.Base32.Decode(secure));
Encode ( int value ) : string

Encodes an integer as a Base32 string.

Use the DecodeToInteger method to decode strings encoded with this method.

Encode ( short values ) : string

Encodes a short array as a Base32 string.

Use the DecodeToShortArray method to decode strings encoded with this method.

Encode ( string value ) : string

Encodes a plain string as a Base32 string.

Use the DecodeToString method to decode strings encoded with this method.

Method Details

Decode() public static method

Takes a string previously generate with the Encode method and returns the original byte array.

public static Decode ( string value ) : byte[]
value string encoded string data.
return byte[]

DecodeToInteger() public static method

Takes a string previously generate with the Encode method and returns the original integer value.

public static DecodeToInteger ( string value ) : int
value string encoded string data.
return int

DecodeToShortArray() public static method

Takes a string previously generate with the Encode method and returns the original short array value.

public static DecodeToShortArray ( string value ) : short[]
value string encoded string data.
return short[]

DecodeToString() public static method

Takes a string previously generate with the Encode method and returns the original string value.

public static DecodeToString ( string value ) : string
value string encoded string data. ///
return string

Encode() public static method

Encodes a byte array as a Base32 encoded string.

The following code will encrypt the string "Hello World" and store the result as a Base32 encoded string in the variable secure.

string secure = Mobile.Base32.Encode( Mobile.Crypto.Encrypt("Hello World"));

secure can be decoded using the following code.

string plain = Mobile.Crypto.Decrypt( Mobile.Base32.Decode(secure));
public static Encode ( byte bytes ) : string
bytes byte Byte array to encode.
return string

Encode() public static method

Encodes an integer as a Base32 string.

Use the DecodeToInteger method to decode strings encoded with this method.

public static Encode ( int value ) : string
value int Integer to be encoded.
return string

Encode() public static method

Encodes a short array as a Base32 string.

Use the DecodeToShortArray method to decode strings encoded with this method.

public static Encode ( short values ) : string
values short An array of shorts to be encoded.
return string

Encode() public static method

Encodes a plain string as a Base32 string.

Use the DecodeToString method to decode strings encoded with this method.

public static Encode ( string value ) : string
value string String to be encoded.
return string