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); } }
public ProtectedString(Crypto crypto, byte[] data) { this.crypto = crypto; this.data = data; }