コード例 #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
ファイル: EjsonCrypto.cs プロジェクト: jakegough/jaytwo.ejson
        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));
        }