您好,欢迎来到花图问答。
搜索
您的当前位置:首页.NET Android 签名验证工具

.NET Android 签名验证工具

来源:花图问答
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private string javaHome;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string JRE_REGISTRY_KEY = @"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment";

            string jreVersion = (string)Registry.GetValue(JRE_REGISTRY_KEY, "CurrentVersion", null);
            string keyName =  jreVersion);

            javaHome = (string)Registry.GetValue(keyName, "JavaHome", null);
        }

        private void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
                e.Effect = DragDropEffects.Copy;
        }

        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (string file in files)
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = "";
                startInfo.FileName = javaHome + "\\bin\\keytool.exe";
                startInfo.Arguments = "-printcert -rfc -jarfile \"" + file + "\"";
                startInfo.UseShellExecute = false;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardError = true;
                startInfo.CreateNoWindow = true;


                Process process = Process.Start(startInfo);
                process.EnableRaisingEvents = true;
                process.Exited += delegate(object s, EventArgs eventArgs)
                {
                    string output = process.StandardOutput.ReadToEnd();
                    if (output != "")
                    {
                        if (output.Contains("证书所有者:"))
                        {
                            if (output.Contains("证书所有者: CN=Louis Lu, OU=Sinyee Inc, O=Sinyee Inc, L=FuZhou, ST=FuJian, C=CN"))
                                MessageBox.Show(Path.GetFileName(file) + " 证书正确", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            else
                                MessageBox.Show(Path.GetFileName(file) + " 证书错误", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                            MessageBox.Show(output, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    string error = process.StandardError.ReadToEnd();
                    if (error != "")
                        MessageBox.Show(error, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                };
            }
        }
    }
}

本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。

热门图文

Copyright © 2019-2025 huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务