private static void CreateXmlKeyFile(string strFile, byte[] pbKeyData) #endif { Debug.Assert(strFile != null); if (strFile == null) { throw new ArgumentNullException("strFile"); } Debug.Assert(pbKeyData != null); if (pbKeyData == null) { throw new ArgumentNullException("pbKeyData"); } #if ModernKeePassLib IOConnectionInfo ioc = IOConnectionInfo.FromFile(strFile); #else IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile); #endif using (Stream s = IOConnection.OpenWrite(ioc)) { using (XmlWriter xw = XmlUtilEx.CreateXmlWriter(s)) { xw.WriteStartDocument(); xw.WriteStartElement(RootElementName); // <KeyFile> xw.WriteStartElement(MetaElementName); // <Meta> xw.WriteStartElement(VersionElementName); // <Version> xw.WriteString("1.00"); xw.WriteEndElement(); // </Version> xw.WriteEndElement(); // </Meta> xw.WriteStartElement(KeyElementName); // <Key> xw.WriteStartElement(KeyDataElementName); // <Data> xw.WriteString(Convert.ToBase64String(pbKeyData)); xw.WriteEndElement(); // </Data> xw.WriteEndElement(); // </Key> xw.WriteEndElement(); // </KeyFile> xw.WriteEndDocument(); } } }
public KcpKeyFile(StorageFile strKeyFile) { Construct(IOConnectionInfo.FromFile(strKeyFile), false); }