public void EncryptionShouldWorkCorrect()
        {
            // Arrange
            using (var csp = new RSACryptoServiceProvider(AlgorithmConstants.KeySize))
            {
                var pubKey  = csp.ExportParameters(false);
                var privKey = csp.ExportParameters(true);

                var str = "helloworld";

                // Act
                var encoded = _service.Encode(str, pubKey);
                var decoded = _service.Decode(encoded, privKey);

                // Assert
                decoded.ShouldBe(str);
            }
        }
Exemplo n.º 2
0
        public static bool IsKeyValid()
        {
            string uuid = "";
            string key = "";

            ReadAuthentication(out uuid, out key);

            if (string.IsNullOrEmpty(uuid) || string.IsNullOrEmpty(key)) return false;

            string encodedSN = EncryptService.Encode(uuid);

            string decoded = EncryptService.Decode(key);

            return string.Compare(encodedSN, key, StringComparison.Ordinal) == 0;
        }