I am trying to convert some java source code to C#.
What is the equivalent of the following Java classes in c#:
- RsaSHA256Signer
- Instant
Thank you
I am trying to convert some java source code to C#.
What is the equivalent of the following Java classes in c#:
Thank you
I am not 100% sure but it might be the following.
https://blogs.msdn.microsoft.com/shawnfa/2008/08/25/using-rsacryptoserviceprovider-for-rsa-sha256-signatures/ for RsaSHA256Signer
So code will look like that :
byte[] data = new byte[] { 0, 1, 2, 3, 4, 5 };
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
byte[] signature = rsa.SignData(data, "SHA256");
if (rsa.VerifyData(data, "SHA256", signature))
{
Console.WriteLine("RSA-SHA256 signature verified");
}
else
{
Console.WriteLine("RSA-SHA256 signature failed to verify");
}
}
For example:
Java:
Instant instant = Instant.now();
C#:
DateTime localDate = DateTime.UtcNow;
https://learn.microsoft.com/en-us/dotnet/api/system.datetime.now?view=netframework-4.8
Additionally, you can look for Noda Time which is a popular library.