C# Класс 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)
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Описание методов

ComputeHash() публичный статический Метод

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
Результат byte[]

ComputeKeyedHash() публичный статический Метод

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
Результат byte[]

GetEpochSeconds() публичный статический Метод

determine the number of seconds since unix epoch
public static GetEpochSeconds ( this current ) : long
current this the date and time to convert
Результат long

ReadExactly() публичный статический Метод

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
Результат byte[]

ToBase64() публичный статический Метод

Base64-encode a byte array.
public static ToBase64 ( this data ) : string
data this byte array to encode.
Результат string

ToByteArray() публичный статический Метод

Retrieve the byte array for a string in UTF8 encoding
public static ToByteArray ( this data ) : byte[]
data this the data string
Результат byte[]

ToHex() публичный статический Метод

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
Результат string

ToISO8601() публичный статический Метод

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
Результат string

URLEncode() публичный статический Метод

a utility method to uri encode a text string
public static URLEncode ( this data ) : string
data this the string
Результат string