- 前文在这里
- 手动方式
- 但是我觉得很麻烦,每次都需要这样操作一遍
- 所以我写了一个编辑器工具
- echo本身是一个输入密码的命令,命令和命令之间要用空格分开
- 还有一个问题是cmd本身是用GBK编码的,他输出的文字也是用GBK,所以接收的时候需要指定编码,否则就是乱码
- 只要在输出中复制自己key的md5就行了
[MenuItem("Tools/获取MD5")]
private static void GetMD5()
{
string getMD5 = "cd .anroid echo 798969|keytool -list -v -keystore C:\\Users\\Sky\\Documents\\user.keystore";
Process CmdProcess = new Process();
CmdProcess.StartInfo.FileName = "cmd.exe";
CmdProcess.StartInfo.CreateNoWindow = true;
CmdProcess.StartInfo.UseShellExecute = false;
CmdProcess.StartInfo.RedirectStandardInput = true;
CmdProcess.StartInfo.RedirectStandardOutput = true;
CmdProcess.StartInfo.RedirectStandardError = true;
CmdProcess.StartInfo.Arguments = "/c " + getMD5;
CmdProcess.Start();
StreamReader reader = new StreamReader(CmdProcess.StandardOutput.BaseStream, Encoding.GetEncoding("gbk"));
string result = reader.ReadToEnd().Trim();
var allLines = result.Split('\n');
foreach (var singleLine in allLines)
{
{
var index = singleLine.IndexOf("别名:");
if (index != -1)
{
var name = singleLine.Substring(index + 3).Trim();
Debug.Log(name);
}
}
{
var index = singleLine.IndexOf("MD5");
if (index != -1)
{
var md5Val = singleLine.Substring(index + 3).Trim().Replace(":", "").Trim();
Debug.Log(md5Val);
}
}
}
CmdProcess.WaitForExit();
CmdProcess.Close();
}