java - using RSA public.key distributed by a web service in android -
I try to secure connections between the About the code, try it: Edit: This is what I use to write something on a file The SDCards are assured from the bottom portion: U can change it accordingly. Android app and
Java Web Services I am with
RSA private / public.key . I will tell you the whole scenario When the Android app is downloaded and installed on a mobile device, it only makes a connection with the web service to get public.key once. And this public.key will be used for all communications with the web service after that Android app. I have succed up with the public key and decrypte with the private key in the same application so far. But now I need to distribute the public key to my Android device customers and save them to this public.key file and use it. Tell me about your second scenario. I need to update these private and public keys for every 2-month example. How can I notify customers about the public key, renew and send them to the new public. Thank you thanks The code below is to request public.key. I can get in the inputstream but public Can not create key and write content in it.
Public connect service (string sngUrl, reference reference) {URL url = new URL (sngUrl) {try} URL connection connection = url.openConnection (); Conection.connect (); InputStream input = new BufferedInputStream (url.openstream (), 8192); Println (convertStreamToString (input)); String dirPath = context.getFilesDir (). GetAbsolutePath () + File.Sseparator + "key"; File Kidware = New File (Dirpath); If (! KeyDir.exists ()) keyDir.mkdirs (); OutputStream Output = New File OptimizeTream (key DIR + "/ public.key"); Byte data [] = new byte [1024]; While ((input.read (data))! = -1) {output.write (data); } Output.flush (); Output.close (); Input.close (); } Hold (exception e) {System.out.println ("HATA:" + e.getMessage ()); E.printStackTrace (); }} Exception: java.io.FileNotFoundException: /data/data/com.shoponway/files/key/public.key
OutputStream Output = New FileApplyput Stream (New File (Dirpath + "/ Public.key")); Regarding updating public keys, yes, customers can download it automatically after connecting to the internet and / or they can check whether the keys have been updated, once the application is started.
fw = new FileWriter (new file (Environment.getExternalStorageDirectory (). GetPath () + "/ MyFolder / public .key")); ... while (some) {fw.write (blaBla); } Fw.flush (); Fw.close ();
environment .getExternalStorage directory (). GetPath ()
Comments
Post a Comment