コード例 #1
0
    private DatabaseConfig LoadDatabaseConfig(XmlElement node)
    {
        HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.Rijndael);

        string strDBType           = string.Empty;
        string strConnectionString = string.Empty;
        string strName             = string.Empty;

        if (node["dbtype"] != null)
        {
            strDBType = node["dbtype"].InnerText;
        }
        if (node["name"] != null)
        {
            strName = node["name"].InnerText;
        }
        if (node["ConnectionString"] != null)
        {
            strConnectionString = node["ConnectionString"].InnerText;
        }

        if (strDBType.Equals("MSSQL"))
        {
            DatabaseConfig config = new DatabaseConfig();
            config.DBType = WebUtils.DBTypeEmun.MSSQL;
            config.name   = strName;
            System.Data.SqlClient.SqlConnectionStringBuilder connStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(strConnectionString);
            try
            {
                connStringBuilder.Password        = crypto.Decrypting(connStringBuilder.Password, keyString);
                connStringBuilder.ApplicationName = "HROneWeb";
                config.ConnectionString           = connStringBuilder.ConnectionString;
            }
            catch
            {
            }
            return(config);
        }
        else
        {
            return(null);
        }
    }
コード例 #2
0
    private DateTime getDateFromKey(string trialKey)
    {
        HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.DES);
        try
        {
            trialKey = base32.ConvertBase32ToBase64(trialKey);

            string realTrialKey = crypto.Decrypting(trialKey, "HROne");
            string strYear      = realTrialKey.Substring(0, 4);
            string strMonth     = realTrialKey.Substring(4, 2);
            string strDay       = realTrialKey.Substring(6, 2);

            return(new DateTime(int.Parse(strYear), int.Parse(strMonth), int.Parse(strDay)));
        }
        catch
        {
            return(new DateTime());
        }
    }