/// <summary> /// Decrypt data using the variant mode. /// </summary> /// <param name="data">16, 32 or 48 hex data to decrypt.</param> /// <returns>Decrypted data.</returns> public string DecryptVariant(string data) { ValidateEncryptDecryptData(data); if (data.Length == 16) { throw new InvalidOperationException("Cannot use 8-byte data with DecryptVariant"); } if (data.Length == 32) { var orgKeyPartB = PartB; PartB = PartB.XorHex(LMK.Variants.GetDoubleLengthVariant(1).PadRight(16, '0')); var result1 = Decrypt(data.Substring(0, 16)); PartB = orgKeyPartB.XorHex(LMK.Variants.GetDoubleLengthVariant(2).PadRight(16, '0')); var result2 = Decrypt(data.Substring(16, 16)); PartB = orgKeyPartB; return(result1 + result2); } else { var orgKeyPartB = PartB; PartB = PartB.XorHex(LMK.Variants.GetTripleLengthVariant(1).PadRight(16, '0')); var result1 = Decrypt(data.Substring(0, 16)); PartB = orgKeyPartB.XorHex(LMK.Variants.GetTripleLengthVariant(2).PadRight(16, '0')); var result2 = Decrypt(data.Substring(16, 16)); PartB = orgKeyPartB.XorHex(LMK.Variants.GetTripleLengthVariant(3).PadRight(16, '0')); var result3 = Decrypt(data.Substring(32, 16)); PartB = orgKeyPartB; return(result1 + result2 + result3); } }
public void PartAOptionalDependsOnPartB_PartBGetAddedLater() { var container = new CompositionContainer(new TypeCatalog(typeof(PartC), typeof(PartA))); var partA = container.GetExportedValue <PartA>(); Assert.Null(partA.ImportB); var partB = new PartB(); container.ComposeParts(partB); Assert.Equal(partA.ImportB, partB); Assert.NotNull(partB.ImportC); }
public override string ToString() { return(string.Format("{0}.{1}.{2}.{3}", PartA.ToString(), PartB.ToString(), PartC.ToString(), PartD.ToString())); }
public void PartAOptionalDependsOnPartB_PartBGetAddedLater() { var container = new CompositionContainer(new TypeCatalog(typeof(PartC), typeof(PartA))); var partA = container.GetExportedValue<PartA>(); Assert.IsNull(partA.ImportB); var partB = new PartB(); container.ComposeParts(partB); Assert.AreEqual(partA.ImportB, partB); Assert.IsNotNull(partB.ImportC); }
public void AddPartB() { this.mPartB = new PartB(); }
public void AddPartB() { this.mPartB = new PartB(); }