Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
 public static bool Verify(string text, string signature)
 {
     return(Verify(text, CPCNUtils.hex2bytes(signature)));
 }