Table of Contents

Struct Sha1Hash

Namespace
Fenrir.Git
Assembly
Fenrir.Git.dll

Structure representing an SHA-1 hash. Guarantees the stored hash is valid, will normalize it to lowercase when converted to a string.

[Struct]
[CompilationMapping(SourceConstructFlags.RecordType)]
public struct Sha1Hash : IEquatable<Sha1Hash>, IStructuralEquatable, IComparable<Sha1Hash>, IComparable, IStructuralComparable
Implements
Inherited Members

Constructors

Sha1Hash(byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte, byte)

public Sha1Hash(byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7, byte byte8, byte byte9, byte byteA, byte byteB, byte byteC, byte byteD, byte byteE, byte byteF, byte byteG, byte byteH, byte byteI, byte byteJ)

Parameters

byte0 byte
byte1 byte
byte2 byte
byte3 byte
byte4 byte
byte5 byte
byte6 byte
byte7 byte
byte8 byte
byte9 byte
byteA byte
byteB byte
byteC byte
byteD byte
byteE byte
byteF byte
byteG byte
byteH byte
byteI byte
byteJ byte

Properties

Byte0

[CompilationMapping(SourceConstructFlags.Field, 0)]
public readonly byte Byte0 { get; }

Property Value

byte

Byte1

[CompilationMapping(SourceConstructFlags.Field, 1)]
public readonly byte Byte1 { get; }

Property Value

byte

Byte2

[CompilationMapping(SourceConstructFlags.Field, 2)]
public readonly byte Byte2 { get; }

Property Value

byte

Byte3

[CompilationMapping(SourceConstructFlags.Field, 3)]
public readonly byte Byte3 { get; }

Property Value

byte

Byte4

[CompilationMapping(SourceConstructFlags.Field, 4)]
public readonly byte Byte4 { get; }

Property Value

byte

Byte5

[CompilationMapping(SourceConstructFlags.Field, 5)]
public readonly byte Byte5 { get; }

Property Value

byte

Byte6

[CompilationMapping(SourceConstructFlags.Field, 6)]
public readonly byte Byte6 { get; }

Property Value

byte

Byte7

[CompilationMapping(SourceConstructFlags.Field, 7)]
public readonly byte Byte7 { get; }

Property Value

byte

Byte8

[CompilationMapping(SourceConstructFlags.Field, 8)]
public readonly byte Byte8 { get; }

Property Value

byte

Byte9

[CompilationMapping(SourceConstructFlags.Field, 9)]
public readonly byte Byte9 { get; }

Property Value

byte

ByteA

[CompilationMapping(SourceConstructFlags.Field, 10)]
public readonly byte ByteA { get; }

Property Value

byte

ByteB

[CompilationMapping(SourceConstructFlags.Field, 11)]
public readonly byte ByteB { get; }

Property Value

byte

ByteC

[CompilationMapping(SourceConstructFlags.Field, 12)]
public readonly byte ByteC { get; }

Property Value

byte

ByteD

[CompilationMapping(SourceConstructFlags.Field, 13)]
public readonly byte ByteD { get; }

Property Value

byte

ByteE

[CompilationMapping(SourceConstructFlags.Field, 14)]
public readonly byte ByteE { get; }

Property Value

byte

ByteF

[CompilationMapping(SourceConstructFlags.Field, 15)]
public readonly byte ByteF { get; }

Property Value

byte

ByteG

[CompilationMapping(SourceConstructFlags.Field, 16)]
public readonly byte ByteG { get; }

Property Value

byte

ByteH

[CompilationMapping(SourceConstructFlags.Field, 17)]
public readonly byte ByteH { get; }

Property Value

byte

ByteI

[CompilationMapping(SourceConstructFlags.Field, 18)]
public readonly byte ByteI { get; }

Property Value

byte

ByteJ

[CompilationMapping(SourceConstructFlags.Field, 19)]
public readonly byte ByteJ { get; }

Property Value

byte

SizeInBytes

Size of the SHA-1 hash in bytes.

public static int SizeInBytes { get; }

Property Value

int

Remarks

Note that this is not the length of the string representation.

Zero

A hash object filled with zeros.

public static Sha1Hash Zero { get; }

Property Value

Sha1Hash

Methods

CompareTo(Sha1Hash)

public override sealed int CompareTo(Sha1Hash obj)

Parameters

obj Sha1Hash

Returns

int

CompareTo(object?)

public override sealed int CompareTo(object? obj)

Parameters

obj object

Returns

int

CompareTo(object?, IComparer)

public override sealed int CompareTo(object? obj, IComparer comp)

Parameters

obj object
comp IComparer

Returns

int

Equals(Sha1Hash)

public override sealed bool Equals(Sha1Hash obj)

Parameters

obj Sha1Hash

Returns

bool

Equals(Sha1Hash, IEqualityComparer)

public bool Equals(Sha1Hash obj, IEqualityComparer comp)

Parameters

obj Sha1Hash
comp IEqualityComparer

Returns

bool

Equals(object?)

public override sealed bool Equals(object? obj)

Parameters

obj object

Returns

bool

Equals(object?, IEqualityComparer)

public override sealed bool Equals(object? obj, IEqualityComparer comp)

Parameters

obj object
comp IEqualityComparer

Returns

bool

GetHashCode()

public override sealed int GetHashCode()

Returns

int

GetHashCode(IEqualityComparer)

public override sealed int GetHashCode(IEqualityComparer comp)

Parameters

comp IEqualityComparer

Returns

int

OfBytes(byte[])

Converts a byte array to a SHA-1 hash object. Will verify the array length.

public static Sha1Hash OfBytes(byte[] bytes)

Parameters

bytes byte[]

Returns

Sha1Hash

OfHexString(string)

Converts a hexadecimal string representation (possibly in a mixed case) into a hash object. Will verify the input data.

public static Sha1Hash OfHexString(string data)

Parameters

data string

Returns

Sha1Hash

ToBytes()

Converts the hash object to a byte array of exactly SizeInBytes bytes.

public byte[] ToBytes()

Returns

byte[]

ToString()

Converts the hash object to a hexadecimal lowercase string representation.

public override string ToString()

Returns

string