Пример #1
0
 public string Sign(byte[] @object, RSAParameters privateKey) =>
 RSACryptoServiceProviderExtensions.Using(rsa => rsa
                                          .ImportKey(privateKey)
                                          .SignData(
                                              @object,
                                              HashAlgorithmName.SHA256,
                                              RSASignaturePadding.Pkcs1)
                                          .ToBase64String()
                                          );
Пример #2
0
 public bool Verify(byte[] @object, string signature, RSAParameters publicKey) =>
 signature.BytesFromBase64().Map(s =>
                                 RSACryptoServiceProviderExtensions.Using(rsa => rsa
                                                                          .ImportKey(publicKey)
                                                                          .VerifyData(
                                                                              @object,
                                                                              s,
                                                                              HashAlgorithmName.SHA256,
                                                                              RSASignaturePadding.Pkcs1))
                                 ).Match(l => false, r => r);