예제 #1
0
        public byte[] ToArray(Crypto crypto)
        {
            byte[] buffer;

            if (this.data != null)
            {
                if (this.crypto.IsEqual(crypto))
                {
                    return(this.data);
                }

                buffer = this.crypto.Decrypt(data);
            }
            else if (this.value != null)
            {
                buffer = Credentials.ToByteArray(this.value);
            }
            else
            {
                return(new byte[0]);
            }

            try
            {
                var b = crypto.Compress(crypto.Encrypt(buffer));

                this.data   = b;
                this.crypto = crypto;

                return(b);
            }
            finally
            {
                Array.Clear(buffer, 0, buffer.Length);
            }
        }
예제 #2
0
 public ProtectedString(Crypto crypto, byte[] data)
 {
     this.crypto = crypto;
     this.data   = data;
 }