/// <summary> /// Construct a new protected string. The string is initialized /// to the value passed in the <c>XorredBuffer</c> object. /// </summary> /// <param name="bEnableProtection">Enable protection or not.</param> /// <param name="xb"><c>XorredBuffer</c> object containing the /// string in UTF-8 representation. The UTF-8 string must not /// be <c>null</c>-terminated.</param> public ProtectedString(bool bEnableProtection, XorredBuffer xb) { if (xb == null) { Debug.Assert(false); throw new ArgumentNullException("xb"); } byte[] pb = xb.ReadPlainText(); try { Init(bEnableProtection, pb); } finally { if (bEnableProtection) { MemUtil.ZeroByteArray(pb); } } }
/// <summary> /// Construct a new protected binary data object. Copy the data from /// a <c>XorredBuffer</c> object. /// </summary> /// <param name="bEnableProtection">Enable protection or not.</param> /// <param name="xbProtected"><c>XorredBuffer</c> object used to /// initialize the <c>ProtectedBinary</c> object.</param> public ProtectedBinary(bool bEnableProtection, XorredBuffer xbProtected) { Debug.Assert(xbProtected != null); if (xbProtected == null) { throw new ArgumentNullException("xbProtected"); } byte[] pb = xbProtected.ReadPlainText(); try { Init(bEnableProtection, pb, 0, pb.Length); } finally { if (bEnableProtection) { MemUtil.ZeroByteArray(pb); } } }