コード例 #1
0
        public static String GenFirma(String request)
        {
            byte[] SignedData   = new byte[128];
            String SignedBase64 = "";
            RSACryptoServiceProvider public_rsa;
            VigiaCryptografi         cfunction;

            public_rsa = new RSACryptoServiceProvider();
            public_rsa.FromXmlString(PUBLIC_KEY);
            cfunction = new VigiaCryptografi(public_rsa, "", "SHA1");

            var private_rsa = new RSACryptoServiceProvider();

            private_rsa.FromXmlString(FULL_KEY);
            byte[] shash = cfunction.Sign(request, private_rsa);
            SignedData   = shash;
            SignedBase64 = Convert.ToBase64String(SignedData);
            return(SignedBase64);
        }
コード例 #2
0
        public static bool IsValidSerial(String signed, String LincenseInfo)
        {
            var public_key = new RSACryptoServiceProvider();

            public_key.FromXmlString(PUBLIC_KEY);
            VigiaCryptografi vcripto = new VigiaCryptografi(public_key, LincenseInfo, "SHA1");

            if (signed == "" || LincenseInfo == "")
            {
                return(false);
            }
            bool result = false;

            try
            {
                result = vcripto.VerifySignature(Convert.FromBase64String(signed));
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }