예제 #1
0
        // Protect the input bytes.
        public byte[] Protect(IProtectionHandler handler, byte[] data)
        {
            long buffersize = handler.GetProtectedContentLength(data.Length, true);

            byte[] outputBuffer = new byte[buffersize];

            handler.EncryptBuffer(0, data, outputBuffer, true);
            return(outputBuffer);
        }
예제 #2
0
        public byte[] Unprotect(IProtectionHandler handler, byte[] data)
        {
            long buffersize = data.Length;

            byte[] clearBuffer = new byte[buffersize];

            var bytesDecrypted = handler.DecryptBuffer(0, data, clearBuffer, true);

            byte[] outputBuffer = new byte[bytesDecrypted];
            for (int i = 0; i < bytesDecrypted; i++)
            {
                outputBuffer[i] = clearBuffer[i];
            }

            return(outputBuffer);
        }