private void Dice_Event(GameObject object_1 = null)
        {
            string[] array = GetRandomStr.Name(1);
            string   value = array[0];

            this.Name_Input.value = value;
            this.Name_Input.GetComponent <UIInput>().value = value;
        }
        public EnctyptVM(IEncryptService encryptService)
        {
            _encryptService     = encryptService;
            RandomSecretCommand = new Command(() =>
            {
                rdStr      = new GetRandomStr();
                SecretText = rdStr.GetRandoms();
            });
            EncryptCommand = new Command(async() =>
            {
                if (await SetKeyTextInputErrorToast())
                {
                    return;
                }
                ResultText = _encryptService.Encrypt(KeyText, SecretText);
            });
            DecryptCommand = new Command(async() =>
            {
                if (await SetKeyTextInputErrorToast())
                {
                    return;
                }
                try
                {
                    ResultText = _encryptService.Decrypt(KeyText, SecretText);
                }
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("错误!", ex.Message, "OK");
                }
            });
            ToClipboardCommand = new Command(async() =>
            {
                if (string.IsNullOrEmpty(ResultText))
                {
                    return;
                }
                await Clipboard.SetTextAsync(ResultText);
            });
            async Task <bool> SetKeyTextInputErrorToast()
            {
                if (string.IsNullOrEmpty(SecretText) || SecretText.Length != 4)
                {
                    await App.Current.MainPage.DisplayAlert("提醒", "特定字符不能为空且长度必须为4!", "好的");

                    return(true);
                }
                if (string.IsNullOrEmpty(KeyText))
                {
                    await App.Current.MainPage.DisplayAlert("提醒", "待加密内容不能为空!", "好的");

                    return(true);
                }
                return(false);
            }
        }
Exemple #3
0
 public static string[] Name(int num)
 {
     if (GetRandomStr.sSurnames == null || GetRandomStr.sFirstNames == null)
     {
         GetRandomStr.IniName();
     }
     if (GetRandomStr.sSurnames == null || GetRandomStr.sFirstNames == null)
     {
         Debug.LogError("随机昵称出错");
         return(null);
     }
     string[]      array  = new string[num];
     System.Random random = new System.Random();
     for (int i = 0; i < num; i++)
     {
         array[i] = GetRandomStr.sSurnames[random.Next(0, GetRandomStr.sSurnames.Length - 1)] + GetRandomStr.sFirstNames[random.Next(0, GetRandomStr.sFirstNames.Length - 1)];
     }
     return(array);
 }