C# Class Akamai.Utils.ExtensionMethods

General utility functions needed to implement the NetStorageKit. Many of these functions are also available as standard parts of other libraries, but this package strives to operate without any external dependencies. Author: [email protected] (Colin Bendell)
Afficher le fichier Open project: surgeforward/AkamaiOPEN-edgegrid-C-Sharp Class Usage Examples

Méthodes publiques

Méthode Description
ComputeHash ( this stream, ChecksumAlgorithm hashType = ChecksumAlgorithm.SHA256, long maxBodySize = null ) : byte[]

Computes the hash of a given InputStream. This is a wrapper over the HashAlgorithm crypto functions.

ComputeKeyedHash ( this data, string key, KeyedHashAlgorithm hashType = KeyedHashAlgorithm.HMACSHA256 ) : byte[]

Computes the HMAC hash of a given byte[]. This is a wrapper over the Mac crypto functions.

GetEpochSeconds ( this current ) : long

determine the number of seconds since unix epoch

ReadExactly ( this stream, long maxCount ) : byte[]

Reads a stream up to @maxCount number of bytes. Less bytes will be returned if the end of the file is reached.

ToBase64 ( this data ) : string

Base64-encode a byte array.

ToByteArray ( this data ) : byte[]

Retrieve the byte array for a string in UTF8 encoding

ToHex ( this data ) : string

Hex encoding wrapper for a byte array. The output will be 2 character padded string in lower case.

ToISO8601 ( this timestamp ) : string

format a date and time into ISO8601 style of "yyyyMMdd'T'HH:mm:ss+0000"

URLEncode ( this data ) : string

a utility method to uri encode a text string

Method Details

ComputeHash() public static méthode

Computes the hash of a given InputStream. This is a wrapper over the HashAlgorithm crypto functions.
public static ComputeHash ( this stream, ChecksumAlgorithm hashType = ChecksumAlgorithm.SHA256, long maxBodySize = null ) : byte[]
stream this the source stream. Use a MemoryStream if uncertain.
hashType ChecksumAlgorithm the Algorithm to use to compute the hash
maxBodySize long
Résultat byte[]

ComputeKeyedHash() public static méthode

Computes the HMAC hash of a given byte[]. This is a wrapper over the Mac crypto functions.
public static ComputeKeyedHash ( this data, string key, KeyedHashAlgorithm hashType = KeyedHashAlgorithm.HMACSHA256 ) : byte[]
data this byte[] of content to hash
key string secret key to salt the hash. This is assumed to be UTF-8 encoded
hashType System.Security.Cryptography.KeyedHashAlgorithm determines which alogirthm to use. The recommendation is to use HMAC-SHA256
Résultat byte[]

GetEpochSeconds() public static méthode

determine the number of seconds since unix epoch
public static GetEpochSeconds ( this current ) : long
current this the date and time to convert
Résultat long

ReadExactly() public static méthode

Reads a stream up to @maxCount number of bytes. Less bytes will be returned if the end of the file is reached.
public static ReadExactly ( this stream, long maxCount ) : byte[]
stream this the stream to read
maxCount long the maximum number of bytes to read
Résultat byte[]

ToBase64() public static méthode

Base64-encode a byte array.
public static ToBase64 ( this data ) : string
data this byte array to encode.
Résultat string

ToByteArray() public static méthode

Retrieve the byte array for a string in UTF8 encoding
public static ToByteArray ( this data ) : byte[]
data this the data string
Résultat byte[]

ToHex() public static méthode

Hex encoding wrapper for a byte array. The output will be 2 character padded string in lower case.
public static ToHex ( this data ) : string
data this a byte array to encode. The assumption is that the string to encode /// is small enough to be held in memory without streaming the encoding
Résultat string

ToISO8601() public static méthode

format a date and time into ISO8601 style of "yyyyMMdd'T'HH:mm:ss+0000"
public static ToISO8601 ( this timestamp ) : string
timestamp this the date and time to convert
Résultat string

URLEncode() public static méthode

a utility method to uri encode a text string
public static URLEncode ( this data ) : string
data this the string
Résultat string