Skip to content

hannesbarbez/BarbezDotEu.Byte

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarbezDotEu.Byte

Contents

ByteHelper type

Namespace

BarbezDotEu.Byte

Summary

Helper class containing diverse static methods that can be used in any type of context.

ByteArrayToString(hash) method

Summary

Generates a string representation of a byte array.

Returns

A string representation of the hash.

Parameters
Name Type Description
hash System.Byte[] The hash to write as string.

StringToByteArray(hex) method

Summary

Converts a "written" byte-array to an actual byte array. e.g. input string: 69CC766AEFAE05F6BE92A529E27D6AC50A0DC73EFB3631534B5E41A9311D56AB.

Returns

The actual byte-array representation.

Parameters
Name Type Description
hex System.String The "written" byte-array to convert.
Remarks

Based on https://stackoverflow.com/a/321404/8669939

ToByteArray() method

Summary

Creates a byte array from the string, using the System.Text.Encoding.Default encoding unless another is specified.

Parameters

This method has no parameters.

CSharpJavaByteConverter type

Namespace

BarbezDotEu.Byte

Summary

Byte array converter allowing for a fast enough and accurate conversion between Java and C# byte arrays.

ConvertCSharpByteArrayToJavaByteArray(cSharpByteArray) method

Summary

Converts a C# byte array (represented as string) into a Java byte array (returned as its string representation).

Returns

The string representation of a Java byte array.

Parameters
Name Type Description
cSharpByteArray System.String The string representation of a C# byte array.

ConvertCSharpStringArrayToJavaByteArray(cSharpByteArray) method

Summary

Converts a C# byte array (represented as string) into a Java byte array (returned as its int representation because Java byte arrays can contain negative values).

Returns

The Java byte array as integer array.

Parameters
Name Type Description
cSharpByteArray System.String[] The string[] representation of a C# byte array.

ConvertJavaByteArrayToCSharpByteArray(javaByteArray) method

Summary

Converts a Java byte array (represented as string) into a C# byte array (returned as its string representation).

Returns

The string representation of a C# byte array.

Parameters
Name Type Description
javaByteArray System.String The string representation of a Java byte array.

ConvertJavaStringArrayToCSharpByteArray(javaByteArray) method

Summary

Converts a Java byte array (represented as string) into a C# byte array (returned as its int representation for consistency).

Returns

The C# byte array as integer array.

Parameters
Name Type Description
javaByteArray System.String[] The string[] representation of a Java byte array.

CryptoHelper type

Namespace

BarbezDotEu.Byte

Summary

Helpers for cryptography.

GetTsqlLikeHashBytes(toHash) method

Summary

Equivalent of T-SQL's HASHBYTES('SHA2_256', )".

Returns

The result of the hash.

Parameters
Name Type Description
toHash System.String The string to hash.