public static string Decrypt(this IJObjectCrypto jObjectCrypto, Stream stream, byte[] privateKey) { var jObject = JObjectTools.GetJObject(stream); jObjectCrypto.Decrypt(jObject, privateKey); return(JObjectTools.GetJson(jObject)); }
public static string DecryptJson(this IJObjectCrypto jObjectCrypto, string json, byte[] privateKey) { var jObject = JObjectTools.GetJObject(json); jObjectCrypto.Decrypt(jObject, privateKey); return(JObjectTools.GetJson(jObject)); }
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}"); }
public static void Decrypt(this IJObjectCrypto jObjectCrypto, JObject jObject, string privateKey) { var privateKeyBytes = HexConverter.HexToBinary(privateKey); jObjectCrypto.Decrypt(jObject, privateKeyBytes); }
public static string Decrypt(this IJObjectCrypto jObjectCrypto, Stream stream, string privateKey) { var privateKeyBytes = HexConverter.HexToBinary(privateKey); return(jObjectCrypto.Decrypt(stream, privateKeyBytes)); }