Skip to content

Commit

Permalink
String Format Options
Browse files Browse the repository at this point in the history
  • Loading branch information
phongnguyend committed Jul 8, 2023
1 parent 3599587 commit d2a39e4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/CryptographyHelper/CryptographyHelper/HashAlgorithms/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,25 @@ public byte[] ComputeHash()
}
}

public string ComputeHashedString()
public string ComputeHashedString(StringFormat returnFormat = StringFormat.Hex)
{
return ComputeHash().ToHexString();
switch (returnFormat)
{
case StringFormat.Hex:
return ComputeHash().ToHexString();
case StringFormat.Base64:
return ComputeHash().ToBase64String();
default:
break;
}

return null; // TODO: throw UnreachableException() instead
}
}
}

public enum StringFormat
{
Hex,
Base64
}
}
}

0 comments on commit d2a39e4

Please sign in to comment.