示例#1
0
        public static string Decrypt(this IJObjectCrypto jObjectCrypto, Stream stream, byte[] privateKey)
        {
            var jObject = JObjectTools.GetJObject(stream);

            jObjectCrypto.Decrypt(jObject, privateKey);
            return(JObjectTools.GetJson(jObject));
        }
示例#2
0
        public static string DecryptJson(this IJObjectCrypto jObjectCrypto, string json, byte[] privateKey)
        {
            var jObject = JObjectTools.GetJObject(json);

            jObjectCrypto.Decrypt(jObject, privateKey);
            return(JObjectTools.GetJson(jObject));
        }
示例#3
0
        private JObject GetDecryptJObject(string json, IPrivateKeyProvider keyProvider)
        {
            var jObject   = JObjectTools.GetJObject(json);
            var publicKey = GetPublicKey(jObject);

            keyProvider = keyProvider ?? new DefaultPrivateKeyProvider();
            if (keyProvider.TryGetPrivateKey(publicKey, out string privateKey))
            {
                _jObjectCrypto.Decrypt(jObject, privateKey);
                return(jObject);
            }

            throw new InvalidOperationException($"Could not find private key for: {publicKey}");
        }
示例#4
0
        public static void Decrypt(this IJObjectCrypto jObjectCrypto, JObject jObject, string privateKey)
        {
            var privateKeyBytes = HexConverter.HexToBinary(privateKey);

            jObjectCrypto.Decrypt(jObject, privateKeyBytes);
        }
示例#5
0
        public static string Decrypt(this IJObjectCrypto jObjectCrypto, Stream stream, string privateKey)
        {
            var privateKeyBytes = HexConverter.HexToBinary(privateKey);

            return(jObjectCrypto.Decrypt(stream, privateKeyBytes));
        }