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)
파일 보기 프로젝트 열기: surgeforward/AkamaiOPEN-edgegrid-C-Sharp 1 사용 예제들

공개 메소드들

메소드 설명
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