예제 #1
0
        /// <summary>
        /// Initializes static members of the <see cref="CoreApi"/> class.
        /// </summary>
        static CoreApi()
        {
            // try loading keys from settings
            byte[] appKey = UserSettingsUtility.LoadAppKey();
            byte[] appSid = UserSettingsUtility.LoadAppSid();

            // if any keys loaded, decrypt them
            if (appKey != null && appSid != null)
            {
                AppSid = Encoding.UTF8.GetString(SecurityUtility.Decrpyt(appSid));
                AppKey = Encoding.UTF8.GetString(SecurityUtility.Decrpyt(appKey));
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CredentialsViewModel"/> class
        /// </summary>
        public CredentialsViewModel()
        {
            // init commands
            this.SaveCommand   = new RelayCommand(x => this.OnSaveCommand());
            this.CancelCommand = new RelayCommand(x => this.OnCancelCommand());

            // init view
            this.view = new CredentialsView(this);

            // try loading keys
            byte[] appKey = UserSettingsUtility.LoadAppKey();
            byte[] appSid = UserSettingsUtility.LoadAppSid();

            // decrypt loaded keys if any
            if (appKey != null && appSid != null)
            {
                this.AppSidText = Encoding.UTF8.GetString(SecurityUtility.Decrpyt(appSid));
                this.AppKeyText = Encoding.UTF8.GetString(SecurityUtility.Decrpyt(appKey));
            }

            // display view
            this.view.ShowDialog();
        }