package com.qy.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;


public class KeyTools {
	public static String getRSAkey(File file,String key,boolean isRsa) {
		try {
			String exec;
			if(isRsa) {
				exec="keytool -printcert -file "+file.getAbsolutePath();
			}else {
				exec="keytool -list -v -keystore "+file.getAbsolutePath()+" -storepass "+key;
			}
			System.out.println(exec);
		Process process=Runtime.getRuntime().exec(exec);
		BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
		String str="",tmp;
		while ((tmp=reader.readLine())!=null) {
			str+=tmp+"\n";
		}
		reader.close();
		System.out.println(str);
		return str;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "null";
	}
	public static void main(String[] args) {
		getRSAkey(new File("D:\\AndroidKeys\\langtian.jks"),"134679",false);
	}
}
