private static string GetKeyHash(string alias, string keyStore, string password)
{
var proc = new Process();
var arguments = @"""keytool -storepass {0} -keypass {1} -exportcert -alias {2} -keystore {3} | openssl sha1 -binary | openssl base64""";
if (Application.platform == RuntimePlatform.WindowsEditor)
{
proc.StartInfo.FileName = "cmd";
arguments = @"/C " + arguments;
}
else
{
proc.StartInfo.FileName = "bash";
arguments = @"-c " + arguments;
}
proc.StartInfo.Arguments = string.Format(arguments, password, password, alias, keyStore);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
var keyHash = new StringBuilder();
while (!proc.HasExited)
{
keyHash.Append(proc.StandardOutput.ReadToEnd());
}
switch (proc.ExitCode)
{
case 255: setupError = ERROR_KEYTOOL_ERROR;
return null;
}
return keyHash.ToString().TrimEnd('\n');
}