/// <summary> /// Unprotects the specified data. /// </summary> /// <param name="data">The data.</param> /// <param name="entropy">The entropy.</param> /// <returns></returns> public byte[] Unprotect(byte[] data, string entropy = "") { var validated = _sign.Decode(data); var decoded = _encrypt.Decode(validated); //need to reverse things done in protect before returning: subtract entropy from the end and ensure it matches var entropyBytes = GetBytes(entropy); var decodedEntropy = new byte[entropyBytes.Length]; var decodedDataLength = decoded.Length - entropyBytes.Length; Array.Copy(decoded, decodedDataLength, decodedEntropy, 0, entropyBytes.Length); var rez = decodedEntropy.SequenceEqual(entropyBytes) ? GetSubArray(decoded, decodedDataLength) : null; return(rez); }
/// <summary> /// Unprotects the specified data. /// </summary> /// <param name="data">The data.</param> /// <param name="entropy">The entropy.</param> /// <returns></returns> public byte[] Unprotect(byte[] data, string entropy = "") { var validated = _sign.Decode(data); return(_encrypt.Decode(validated)); }