Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中将publickey.xml文件的路径添加到InputStream?将文件publickey.xml放在哪里?_Android_Xml_Rsa_Inputstream_Public Key Encryption - Fatal编程技术网

如何在android中将publickey.xml文件的路径添加到InputStream?将文件publickey.xml放在哪里?

如何在android中将publickey.xml文件的路径添加到InputStream?将文件publickey.xml放在哪里?,android,xml,rsa,inputstream,public-key-encryption,Android,Xml,Rsa,Inputstream,Public Key Encryption,//如何在此处放置publickeyfile.xml的路径 InputStream in = //获取inputstream的ObjectPNutStream ObjectInputStream oin = new ObjectInputStream(new BufferedInputStream(in)); try { BigInteger m = (BigInteger) oin.readObject(); BigInteger e = (BigInteger) oin.readO

//如何在此处放置publickeyfile.xml的路径

InputStream in =
//获取inputstream的ObjectPNutStream

  ObjectInputStream oin =
new ObjectInputStream(new BufferedInputStream(in));
  try {
BigInteger m = (BigInteger) oin.readObject();
BigInteger e = (BigInteger) oin.readObject();
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(m, e);
KeyFactory fact = KeyFactory.getInstance("RSA");
PublicKey pubKey = fact.generatePublic(keySpec);

  } catch (Exception e) {
throw new RuntimeException("Spurious serialisation error", e);
  } finally {
oin.close();
  }
  • 在项目中创建一个res>raw文件夹
  • 将publickeyfile.xml文件放入新文件夹
  • “Inputstream is=myResources.openRawResource(R.raw.publickeyfile)”
  • ……应该行得通