C# Class StreamCryptor.Helper.Utils

Show file Open project: bitbeans/StreamCryptor

Public Methods

Method Description
AddPkcs7Padding ( byte data, int paddingLength ) : byte[]

Fill up an array with Pkcs7 padding.

GetChecksum ( byte array ) : string

Returns a SHA256 byte[] checksum.

GetChecksum ( string path ) : string

Returns a SHA256 file checksum.

GetEphemeralEncryptionKey ( byte ephemeralKey ) : byte[]

Extract the encryption key from the ephemeralKey.

GetEphemeralHashKey ( byte ephemeralKey ) : byte[]

Extract the hash key from the ephemeralKey.

GetRandomFileName ( int length, string fileExtension ) : string

Generates a random filename of given length.

IntegerToLittleEndian ( int data ) : byte[]

Converts an integer to a little endian byte array.

PaddedByteArrayToString ( byte paddedByteArray ) : string

Converts a padded byte array to a unpadded string.

RemovePkcs7Padding ( byte paddedByteArray ) : byte[]

Removes the Pkcs7 padding of an array.

Private Methods

Method Description
StringToPaddedByteArray ( string str, int paddingLength ) : byte[]

Method Details

AddPkcs7Padding() public static method

Fill up an array with Pkcs7 padding.
public static AddPkcs7Padding ( byte data, int paddingLength ) : byte[]
data byte The source array.
paddingLength int The length of the padding.
return byte[]

GetChecksum() public static method

Returns a SHA256 byte[] checksum.
public static GetChecksum ( byte array ) : string
array byte A byte array.
return string

GetChecksum() public static method

Returns a SHA256 file checksum.
public static GetChecksum ( string path ) : string
path string The full path.
return string

GetEphemeralEncryptionKey() public static method

Extract the encryption key from the ephemeralKey.
ephemeralKey
public static GetEphemeralEncryptionKey ( byte ephemeralKey ) : byte[]
ephemeralKey byte The 64 byte ephemeralKey.
return byte[]

GetEphemeralHashKey() public static method

Extract the hash key from the ephemeralKey.
ephemeralKey
public static GetEphemeralHashKey ( byte ephemeralKey ) : byte[]
ephemeralKey byte The 64 byte ephemeralKey.
return byte[]

GetRandomFileName() public static method

Generates a random filename of given length.
A file extension must start with: .
public static GetRandomFileName ( int length, string fileExtension ) : string
length int length of the random string.
fileExtension string a file extension
return string

IntegerToLittleEndian() public static method

Converts an integer to a little endian byte array.
public static IntegerToLittleEndian ( int data ) : byte[]
data int An integer.
return byte[]

PaddedByteArrayToString() public static method

Converts a padded byte array to a unpadded string.
public static PaddedByteArrayToString ( byte paddedByteArray ) : string
paddedByteArray byte The padded byte array.
return string

RemovePkcs7Padding() public static method

Removes the Pkcs7 padding of an array.
public static RemovePkcs7Padding ( byte paddedByteArray ) : byte[]
paddedByteArray byte The padded array.
return byte[]