コード例 #1
0
ファイル: Plugin.cs プロジェクト: aXe1/KeeYaOtp
 private void SprEngine_FilterCompile(object sender, SprEventArgs e)
 {
     if (((e.Context.Flags & SprCompileFlags.ExtActive) == SprCompileFlags.ExtActive) &&
         e.Text.Contains(yaotpPlaceholder) &&
         e.Context.Entry.Strings.Exists(OtpDataUtils.Key) &&
         OtpDataUtils.TryParseOtpData(e.Context.Entry.Strings.Get(OtpDataUtils.Key).ReadString(), out var secret, out var pin))
     {
         var otpString = (new Yaotp(secret, pin, () => DateTime.UtcNow)).ComputeOtp();
         e.Text = StrUtil.ReplaceCaseInsensitive(e.Text, yaotpPlaceholder, otpString);
     }
 }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: aXe1/KeeYaOtp
 private void ProcessEntry(PwEntry entry, OnSuccessDelegate onSuccess)
 {
     if (entry.Strings.Exists(OtpDataUtils.Key))
     {
         var data = entry.Strings.Get(OtpDataUtils.Key).ReadString();
         if (OtpDataUtils.TryParseOtpData(data, out var secret, out var pin) && pin.Length == secret.PinLength)
         {
             onSuccess(new Yaotp(secret, pin, () => DateTime.UtcNow));
         }
         else
         {
             MessageBox.Show(_host.MainWindow, string.Format(Properties.Strings.Plugin_InvalidData, OtpDataUtils.Key), Properties.Strings.Plugin_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }