public static bool Verify(string text, byte[] signature) { try { byte[] hash = CPCNUtils.Hash(text); bool isValid = rsaPKCS1SignatureDeformatter.VerifySignature(hash, signature); if (isValid) { return(true); } else { return(false); } } catch (CryptographicException e) { throw e; } catch (SystemException e) { throw e; } }
public static string Sign(string data) { try { byte[] hash = CPCNUtils.Hash(data); byte[] signature = rsaPKCS1SignatureFormatter.CreateSignature(hash); string sig = CPCNUtils.ConvertBytesToHexString(signature); return(sig); } catch (CryptographicException e) { throw e; } catch (SystemException e) { throw e; } }