private void MarshallSite(StringBuilder target, ISite site)
        {
            var passParams = ConvertToPaddedString($"{SiteTypeHelper.GetType(site.PasswordType)}:{(int)site.AlgorithmVersion}:{site.SiteCounter}", 8);

            var loginName = ConvertToPaddedString(site.UserName); // aka. LoginName
            var siteName  = ConvertToPaddedString(site.SiteName);

            var exportLine = $"{DateTime.FromFileTime(site.LastUsed).ToUniversalTime():yyyy-MM-ddTHH\\:mm\\:ssZ}  {ConvertToPaddedString(0, 8)}  {passParams}  {loginName}\t{siteName}\t{string.Empty}"; // password

            target.Append(exportLine).Append('\n');
        }
 private void MarshallHeader(StringBuilder target, string userName)
 {
     target.Append("# Master Password site export\n");
     target.Append("#     ").Append("Export of site names and stored passwords (unless device-private) encrypted with the master key.").Append('\n');
     target.Append("# \n");
     target.Append("##\n");
     target.Append("# Format: 1\n");
     target.Append("# Date: ").Append(DateTime.UtcNow.ToString("o")).Append('\n');
     target.Append("# User Name: ").Append(userName).Append('\n');
     target.Append("# Full Name: ").Append(userName).Append('\n');
     target.Append("# Avatar: ").Append("0").Append('\n');
     //target.Append("# Key ID: ").Append(/*user.exportKeyID()*/"").Append('\n');
     target.Append("# Version: ").Append(/*MasterKey.Version.CURRENT.toBundleVersion()*/ "0").Append('\n');
     target.Append("# Algorithm: ").Append(/*MasterKey.Version.CURRENT.toInt()*/ "0").Append('\n');
     target.Append("# Default Type: ").Append($"{SiteTypeHelper.GetType(SiteType.GeneratedMaximum)}").Append('\n');
     target.Append("# Passwords: ").Append(/*this.contentMode.name()*/ "PROTECTED").Append('\n');
     target.Append("##\n");
     target.Append("#\n");
     target.Append("#               Last     Times  Password                      Login\t                     Site\tSite\n");
     target.Append("#               used      used      type                       name\t                     name\tpassword\n");
 }
        /*private Header UnmarshallHeader(string line)
         * {
         *
         * }*/

        private ISite UnmarshallSite(string line)
        {
            if (line?.StartsWith("#") ?? true)
            {
                return(null);
            }

            var match = _unmarshallFormats[1].Match(line);

            if (match.Success)
            {
                return(new Site
                {
                    AlgorithmVersion = KeyVersionHelper.FromInt(Convert.ToInt32(match.Groups[4].Value.Replace(":", ""))),
                    LastUsed = Convert.ToDateTime(match.Groups[1].Value).ToFileTimeUtc(),
                    SiteName = match.Groups[7].Value,
                    PasswordType = SiteTypeHelper.FromInt(Convert.ToInt32(match.Groups[3].Value)),
                    SiteCounter = Convert.ToInt32(match.Groups[5].Value.Replace(":", "")),
                    UserName = match.Groups[6].Value,
                });
            }

            return(null);
        }
 public PasswordTypeMapping(string name)
 {
     Type = SiteTypeHelper.ForName(Name = name);
 }
 public PasswordTypeMapping(SiteType type)
 {
     Name = SiteTypeHelper.GetShortName(Type = type);
 }