<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.rc6.appsrc6">
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage"/>
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER"
tools:ignore="ProtectedPermissions" />
<application
android:allowBackup="true"
android:requestLegacyExternalStorage="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppsRC6"
tools:targetApi="31">
<activity
android:name=".Loading"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".appSD" android:label="@string/app_name" />
<activity android:name=".Login" />
<activity android:name=".Enkrip" />
<activity android:name=".Arsip" />
<activity android:name=".Setting" />
<activity android:name=".Dekrip" />
<activity android:name=".UpdatePass" />
</application>
</manifest>
package com.rc6.appsrc6; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import android.content.ContentUris; import android.content.Context; import static android.os.Build.VERSION.SDK_INT; import android.Manifest; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.FileUtils; import android.provider.DocumentsContract; import android.provider.MediaStore; import android.provider.OpenableColumns; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.google.android.gms.common.util.IOUtils; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.nio.channels.FileChannel; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.Base64; //import android.util.Base64; import java.util.Date; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; public class Enkrip extends AppCompatActivity { RadioGroup radioGroup1; String mypath = ""; String mypathOut = ""; String filePath = ""; ProgressDialog pDialog; Button btnOpen; String SDCARD = "9016-4EF8";//sdcard0 sdcard 9016-4EF8 private static final String TAG = "APP"; Button btnEnkip; Button btnDekrip; EditText txtnama, txtPath, txtTime, txtNote, txtpassword; RadioButton radPa, radPi; String statusbaca = "Encrypt"; private static final int PICK_IMAGE = 1; private static int w=32, r=20; private static final double e = Math.E; private static final double goldenRatio = 1.6180339887496482; private static int Pw=0xb7e15163, Qw=0x9e3779b9; private static int[] S; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.enkrip); File rootDataDir = Enkrip.this.getFilesDir(); Log.v("Path Intsaller:", rootDataDir.toString()); int permissionCheck1 = ContextCompat.checkSelfPermission(Enkrip.this, Manifest.permission.WRITE_CALENDAR); int permissionCheck2 = ContextCompat.checkSelfPermission(Enkrip.this, Manifest.permission.READ_EXTERNAL_STORAGE); int permissionCheck3 = ContextCompat.checkSelfPermission(Enkrip.this, Manifest.permission.WRITE_EXTERNAL_STORAGE); int permissionCheck4 = ContextCompat.checkSelfPermission(Enkrip.this, Manifest.permission.WRITE_CALENDAR); int permissionCheck5 = ContextCompat.checkSelfPermission(Enkrip.this, Manifest.permission.WRITE_CALENDAR); // Here, Enkrip.this is the current activity if (ContextCompat.checkSelfPermission(Enkrip.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(Enkrip.this, Manifest.permission.READ_CONTACTS)) { } else { ActivityCompat.requestPermissions(Enkrip.this, new String[]{Manifest.permission.WRITE_CALENDAR}, 0); ActivityCompat.requestPermissions(Enkrip.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0); ActivityCompat.requestPermissions(Enkrip.this, new String[]{Manifest.permission.WRITE_CALENDAR}, 0); ActivityCompat.requestPermissions(Enkrip.this, new String[]{Manifest.permission.READ_CONTACTS}, 0); ActivityCompat.requestPermissions(Enkrip.this, new String[]{Manifest.permission.READ_CONTACTS}, 0); } } ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.MANAGE_EXTERNAL_STORAGE }, 1 ); if (SDK_INT >= Build.VERSION_CODES.R) { if (Environment.isExternalStorageManager()) { } else { Intent intent = new Intent(); intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); Uri uri = Uri.fromParts("package", this.getPackageName(), null); intent.setData(uri); startActivity(intent); } } radioGroup1= (RadioGroup) findViewById(R.id.radioGroup1); txtpassword = (EditText) findViewById(R.id.txtpassword); txtpassword.setText("1234567890123456"); btnOpen = (Button) findViewById(R.id.btnOpen); btnDekrip = (Button) findViewById(R.id.btnclear); txtPath = (EditText) findViewById(R.id.txtpath);//save dekrip File file = Environment.getExternalStorageDirectory(); mypath = file.getAbsolutePath();////storage/emulated/0/ String pathnew = Environment.getExternalStorageDirectory().toString(); txtTime = (EditText) findViewById(R.id.txttime); txtNote = (EditText) findViewById(R.id.txtnote); txtnama = (EditText) findViewById(R.id.txtnama); txtNote.setText(pathnew); txtPath.setText(mypath); String AL=" content://com.sec.android.app.myfiles.FileProvider/external/storage/9016-4EF8/rc6/doc3.txt"; String ALX="/external/storage/9016-4EF8/rc6/doc3.txt"; File xc=new File(AL); String AL1=xc.getAbsolutePath().toString(); String AL2="?"; try { AL2=xc.getCanonicalPath().toString(); } catch (IOException ex) { ex.printStackTrace(); } // cetak("PathAL0", AL); // cetak("PathAL1", AL1); // cetak("PathAL2", AL2); // bacaFile(AL); // bacaFile(AL1); // bacaFile(AL1); // cetak("Path0", pathnew); // cetak("Path1", mypath); txtnama.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent gintent = new Intent(); Uri mydir = Uri.parse(mypath); gintent.setDataAndType(mydir, "*/*"); //gintent.setType("image/*|application/pdf|audio/*"); //gintent.setType("image/*");//PDF image gintent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(gintent, "Select Data"), PICK_IMAGE); } catch (Exception e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); Log.e(e.getClass().getName(), e.getMessage(), e); } } }); btnEnkip = (Button) findViewById(R.id.btnProcess); btnEnkip.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { String keyText=txtpassword.getText().toString(); String txtsrc=txtnama.getText().toString(); String txtdst=txtPath.getText().toString(); if(txtsrc.length()<5 16="" aca="" arg0="" assword="" awal="" bersih="" btndekrip.setenabled="" btndekrip.setonclicklistener="" btndekrip.settext="" btnenkip.setenabled="" btnopen.setenabled="" btnopen.setonclicklistener="" btnopen.setvisibility="" cetak="" dahulu="" decmyword="" dekrip...dan="" dekrip="" di="" documents="" dokumen="" else="" encrypt="" enkrip...dan="" enkrip="" enmyword="" false="" file="" filepath="" findviewbyid="" harus="" hasilnya="" id.radpa="" id.radpi="" iew.gone="" iew="" if="" ilakan="" ilihan="" karaketer="" keytext.length="" keytext="txtpassword.getText().toString();" lengkapi="" mau="" milidetik="" nama="" new="" nkrip.this="" note="" onclick="" pada="" paths.indexof="" paths="" pdf="" pilih="" prosesbaca="" public="" radiogroup1.check="" radpa.setchecked="" radpa.setonclicklistener="" radpa="(RadioButton)" radpi.setonclicklistener="" radpi="(RadioButton)" roses="" show="" statusbaca="" string="" tatus="" time="" toast.length_short="" toast.maketext="" tring="" true="" tulis="" txtdst.length="" txtdst="txtPath.getText().toString();" txtnama.settext="" txtnote.setenabled="" txtnote.settext="" txtpath.setenabled="" txtpath.settext="" txtpath="" txtsrc.length="" txtsrc="txtnama.getText().toString();" txttime.setenabled="" txttime.settext="" verride="" view.onclicklistener="" void="" yang="">0){ File file = new File(Environment.getExternalStorageDirectory(), paths); Uri path = Uri.fromFile(file); Intent pdfOpenintent = new Intent(Intent.ACTION_VIEW); pdfOpenintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); pdfOpenintent.setDataAndType(path, "application/pdf"); try {startActivity(pdfOpenintent); } catch (ActivityNotFoundException e) { } } else if(paths.indexOf(".txt")>0){ try {bacaFile(paths); } catch (Exception eee) { } } else{ try { File x = new File(paths); openFile(x); } catch(Exception eee){ } } } String getNPath(String fullPath) { String AL = ""; int index = fullPath.lastIndexOf("\\"); String fileName = fullPath; if (index >= 3) { fileName = fullPath.substring(index + 1); AL = fullPath.replaceAll(fileName, "") + "ENCRC6" + fileName; } else { index = fullPath.lastIndexOf("/"); if (index > 3) { fileName = fullPath.substring(index + 1); AL = fullPath.replaceAll(fileName, "") + "ENCRC6" + fileName; } else { int dot = fullPath.lastIndexOf("."); String ext = fullPath.substring(dot + 1); AL = fullPath + "ENCRC6." + ext; } } return AL; } private void openFile(File url) { Toast.makeText(this, "Load/Open File "+String.valueOf(url), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(Intent.ACTION_VIEW); try { Uri uri = Uri.fromFile(url); if (url.toString().contains(".doc") || url.toString().contains(".docx")) { // Word document intent.setDataAndType(uri, "application/msword"); } else if (url.toString().contains(".pdf")) { // PDF file intent.setDataAndType(uri, "application/pdf"); } else if (url.toString().contains(".ppt") || url.toString().contains(".pptx")) { // Powerpoint file intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (url.toString().contains(".xls") || url.toString().contains(".xlsx")) { // Excel file intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (url.toString().contains(".zip") || url.toString().contains(".rar")) { // WAV audio file intent.setDataAndType(uri, "application/x-wav"); } else if (url.toString().contains(".rtf")) { // RTF file intent.setDataAndType(uri, "application/rtf"); } else if (url.toString().contains(".wav") || url.toString().contains(".mp3")) { // WAV audio file intent.setDataAndType(uri, "audio/x-wav"); } else if (url.toString().contains(".gif")) { // GIF file intent.setDataAndType(uri, "image/gif"); } else if (url.toString().contains(".jpg") || url.toString().contains(".jpeg") || url.toString().contains(".png")) { // JPG file intent.setDataAndType(uri, "image/jpeg"); } else if (url.toString().contains(".txt")) { // Text file intent.setDataAndType(uri, "text/plain"); } else if (url.toString().contains(".3gp") || url.toString().contains(".mpg") || url.toString().contains(".mpeg") || url.toString().contains(".mpe") || url.toString().contains(".mp4") || url.toString().contains(".avi")) { // Video files intent.setDataAndType(uri, "video/*"); } else { intent.setDataAndType(uri, "*/*"); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, "No application found which can open the file", Toast.LENGTH_SHORT).show(); } } String TEMP=""; public String getPath0(Uri uri,Context context) { TEMP=""; String[] projection = {MediaStore.Images.Media.DATA}; Cursor cursor = managedQuery(uri, projection, null, null, null); if (cursor != null) { try { //Below code works fine before 18 API :- int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String NF0=cursor.getString(column_index); cetak("Baca CARA0",NF0); return NF0; } catch(Exception ee){ //return getNull(uri, this); //String NF0=getPathB(this, uri); //String NF0=getPathC(uri, this); String NF0=getNull(uri, this,""); cetak("Baca CARA1",NF0); return NF0; } finally { if (cursor != null) { cursor.close(); } } } else { String NF0=getNull(uri, this,""); cetak("Baca CARA2",NF0); return NF0; } } public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Uri selectedImageUri = null; switch (requestCode) { case PICK_IMAGE: if (resultCode == Activity.RESULT_OK) { selectedImageUri = data.getData(); } break; } if (selectedImageUri != null) { String A1 = selectedImageUri.getPath(); String B1 = getPath0(selectedImageUri,this); if (A1 != null && A1.indexOf(".")>0) { filePath = A1; Log.v("filePath2", filePath); //String NF1 = selectedImageUri.getPath(); // "/mnt/sdcard/FileName.mp3" //content://media/external/file/137171 //String NF2 = selectedImageUri.toString(); // "file:///mnt/sdcard/FileName.mp3" //content:/media/external/file/137171#/external/file/137171 // A1:/external/storage/9016-4EF8/rc6/ENCRC6doc1.docx // B1:/storage/emulated/0/Documents/myRC6/.DT20230813_065057.xxx // /external/storage/9016-4EF8/rc6/ENCRC6doc1.docx } else if (B1 != null && B1.indexOf(".")>0) { filePath = B1; Log.v("filePath1", filePath); ///external/storage/9016-4EF8/rc6/TENCRC6doc1.docx } else { filePath=""; Toast.makeText(getApplicationContext(), "Unknown path", Toast.LENGTH_LONG).show(); Log.e("filePath", "Unknown path"); } Log.v("Baca=", "A1:" + A1 + "#B1:" + B1 + "#" + filePath); if (filePath.indexOf(":") > 0 || (filePath + "").length() < 4 || filePath.indexOf(".")<4 awal="" btndekrip.setenabled="" btnenkip.setenabled="" btnopen.setenabled="" doc2.txt="" else="" filepath.indexof="" filepath="" getapplicationcontext="" if="" load:="" rc6="" sdcard="" show="" storage="" toast.length_long="" toast.maketext="" true="" txtnama.settext="">0){ mypathOut= filePath.replaceAll("ENCRC6","DECRC6"); txtPath.setText(mypathOut); btnEnkip.setEnabled(false); pesan("Anda Memilih Proses Untuk Dekrip"); btnEnkip.setEnabled(false); btnDekrip.setEnabled(true); radPi.setChecked(true); } else { mypathOut = getNPath(filePath); txtPath.setText(mypathOut); pesan("Anda Memilih Proses Untuk Enkrip"); btnEnkip.setEnabled(true); btnDekrip.setEnabled(false); radPa.setChecked(true); } cetak("Path1", filePath); cetak("Path2", filePath); cetak("Path3", mypathOut); } } } void ENmyword(){ long start=System.currentTimeMillis(); String keyText=txtpassword.getText().toString(); String txtsrc=txtnama.getText().toString();//SRC String txtdst=txtPath.getText().toString();//DST String fileName=txtsrc; cetak("Baca File ",fileName); cetak("Baca Posisi Encript ",txtdst); byte[]key=getByte2(keyText); Path path = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { path = Paths.get(fileName); } try { byte[] data = Files.readAllBytes(path); byte []ciper= encrypt(data, key); String NF=txtdst; saveByte(ciper,NF); sukses("Enkrip Berhasil","Path Simpan di:"+txtdst); } catch (IOException ex) { //Logger.getLogger(RC6.class.getName()).log(Level.SEVERE, null, ex); } long end=System.currentTimeMillis(); String selisih=((end - start) / 1000.0) + " Milidetik"; txtTime.setText(selisih); } void DECmyword(){ String keyText=txtpassword.getText().toString(); String txtsrc=txtnama.getText().toString(); String txtdst=txtPath.getText().toString(); if(txtsrc.indexOf("ENC")>0){ PROSESDEKRIP2( keyText, txtdst, txtsrc); } else { PROSESDEKRIP1(keyText,txtdst); } } void PROSESDEKRIP1(String keyText, String txtdst){ long start=System.currentTimeMillis(); //Proses Dekrip setelah tombol enkrip ditekan.... //FIle yg mau di Dekrip dihasil dari file bentukan tombol ENkrip yaitu di txtPath String NFTUJUAN = txtdst.replaceAll("ENCRC6", "DECRC6"); String fileName = txtdst; cetak("fileName", fileName); byte[] key = getByte2(keyText); Path path = null; path = Paths.get(fileName); //path = Paths.get(TEMP); try { byte[] data = new byte[0]; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { data = Files.readAllBytes(path); } byte[] ciper = decrypt(data, key); saveByte(ciper, NFTUJUAN); sukses("Proses Dekrip Langsung Berhasil", "Path Simpan di:" + NFTUJUAN); } catch (IOException ex) { //Logger.getLogger(RC6.class.getName()).log(Level.SEVERE, null, ex); } long end=System.currentTimeMillis(); String selisih=((end - start) / 1000.0) + " Milidetik"; txtTime.setText(selisih); } void PROSESDEKRIP2(String keyText, String txtdst, String txtsrc){ long start=System.currentTimeMillis(); int dot = txtsrc.lastIndexOf("."); String ext = txtsrc.substring(dot + 1); String namafile=getNM(txtsrc); cetak("Baca u namafile1",namafile); namafile=namafile.replaceAll("."+ext,""); cetak("Baca u namafile2",namafile); // String newNF=getTPath(txtsrc); //Proses Dekrip setelah tombol Browse File Enkrip ditekan.... //FIle yg mau di Dekrip dihasil dari file bentukan tombol Cari yaitu di txtNama cetak("Baca u SRCDiDekrip",txtsrc); cetak("Baca u SRCDiDekrip..",filePath); cetak("Baca u DSTDiDekrip",txtdst); byte[] key = getByte2(keyText); Path path = null; path = Paths.get(TEMP);//txtsrc // try { byte[] data = new byte[0]; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { try { data = Files.readAllBytes(path); cetak("Baca Save0",data.toString()); } catch (IOException ex) { ex.printStackTrace(); cetak("Baca Save1","ERRS1:"+ex.toString()); } } byte[] ciper = decrypt(data, key); try { cetak("Baca Save2","MAU SAVE KE :"+TEMP); saveByte2(ciper, TEMP,namafile,ext);//txtdst } catch (IOException ex) { ex.printStackTrace(); cetak("Baca Save3","ERRS2:"+ex.toString()); } // } catch (IOException ex) { // //Logger.getLogger(RC6.class.getName()).log(Level.SEVERE, null, ex); // sukses("Proses Dekrip ..Gagal Simpan ", "Path Gagal Simpan di:" + NFTUJUAN); // } long end=System.currentTimeMillis(); String selisih=((end - start) / 1000.0) + " Milidetik"; txtTime.setText(selisih); } private boolean rename(File from, File to) { return from.getParentFile().exists() && from.exists() && from.renameTo(to); } void analisa(){ long start=System.currentTimeMillis(); String plainText = "This is an myRC6"; String keyText = "This is an examp";//16digit byte[]data=getByte2(plainText); byte[]key=getByte2(keyText); byte []ciper= encrypt(data, key); String chipper=setString2(ciper); cetak("plainText",plainText); cetak("keyText",keyText); cetak("Chipper",chipper); byte []dekrip= decrypt(ciper, key); String dekriptext=setString2(dekrip); cetak("dekriptext",dekriptext); long end=System.currentTimeMillis(); String selisih=((end - start) / 1000.0) + " Milidetik"; cetak("Waktu Proses ENkrip+Dekrip ",selisih); } byte []getByte(String plainText){ byte[] output = plainText.getBytes(StandardCharsets.UTF_8); System.out.println("Text : " + plainText); String base64encoded = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { base64encoded = Base64.getEncoder().encodeToString(output); } System.out.println("Text [Base64] : " + base64encoded); return output; } String setString(byte[]output){ String base64encoded = Base64.getEncoder().encodeToString(output); return base64encoded; } byte []getByte2(String plainText){ byte[] bytes = plainText.getBytes(StandardCharsets.UTF_8); return bytes; } String setString2(byte[]output){ String s = new String(output, StandardCharsets.UTF_8); return s; } void cetak(String v1, String v2) { Log.v("# " + v1, "RC6:" + v2); } private void saveByte(byte[] dataDecrypt,String NF) throws IOException { Path path = Paths.get(NF); Files.write(path, dataDecrypt); //creates, overwrites cetak("Baca Hasil","File Berhasil di dekripsi ! lihat di : " + NF); } private void saveByte2(byte[] dataDecrypt,String NF,String namafile,String ext) throws IOException { Path path = Paths.get(NF); Files.write(path, dataDecrypt); //creates, overwrites String NF2=NF.replaceAll("xxx",ext); NF2=NF2.replaceAll(".DT",namafile); File currentFile = new File(NF); File newFile = new File(NF2); if (rename(currentFile, newFile)) { //Success cetak("Baca Rename", "Success Rename "+NF+" TO "+NF2); cetak("Baca Hasil","File Berhasil di dekripsi ! lihat di : " + NF2); sukses("Dekrip Sukses !","Cek Di:"+NF2); } else { //Fail cetak("Baca Rename", "Fail Rename "+NF+" TO "+NF2); cetak("Baca Hasil","File Berhasil di dekripsi ! lihat di : " + NF); sukses("Dekrip Gagal !","Cek Di:"+NF); } }4>5> String getTPath(String fullPath) { String AL = ""; int index = fullPath.lastIndexOf("\\"); String fileName = fullPath; if (index >= 3) { fileName = fullPath.substring(index + 1); AL = fullPath.replaceAll(fileName, "") + "T" + fileName; } else { index = fullPath.lastIndexOf("/"); if (index > 3) { fileName = fullPath.substring(index + 1); AL = fullPath.replaceAll(fileName, "") + "T" + fileName; } else { int dot = fullPath.lastIndexOf("."); String ext = fullPath.substring(dot + 1); AL = fullPath + "Temp." + ext; } } return AL; } public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { finish(); return true; } return super.onKeyDown(keyCode, event); } public void lengkapi(String item) { new AlertDialog.Builder(this) .setTitle("Lengkapi Data") .setMessage(item) .setNeutralButton("Tutup", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { } }).show(); } public void pesan(String attr) { new AlertDialog.Builder(this) .setTitle("CEK:RC6 INFORMASI") .setMessage(attr) .setNeutralButton("Tutup", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { } }).show(); } public void sukses(String head,String attr) { new AlertDialog.Builder(this) .setTitle(head) .setMessage(attr) .setNeutralButton("Tutup", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { } }).show(); } //=============================== String getNull(Uri contentUri,Context context,String NF) { File folder; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { folder = new File (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)+ "/"+ "myRC6" ); } else { folder = new File(Environment.getExternalStorageDirectory() + "/"+ "myRC6"); } // if you want to save the copied image temporarily for further process use .TEMP folder otherwise use your app folder where you want to save String TEMP_DIR_PATH = folder.getAbsolutePath();// + "/.TEMP_CAMERA.xxx"; //copy file and send new file path String fileName = getFilename(); if (!TextUtils.isEmpty(fileName)) { File dir = new File(TEMP_DIR_PATH); dir.mkdirs(); cetak("Baca BACKUP",dir+"=&&="+ fileName); File copyFile = new File(dir, fileName); copy(context, contentUri, copyFile); String NF0=copyFile.getAbsolutePath(); TEMP=NF0; cetak("Baca BACKUP NF0",NF0); return NF0; } return null; } public static void copy(Context context, Uri srcUri, File dstFile) { try { InputStream inputStream = context.getContentResolver().openInputStream(srcUri); if (inputStream == null) return; OutputStream outputStream = new FileOutputStream(dstFile); IOUtils.copyStream(inputStream, outputStream); inputStream.close(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } public static String getFilename() { String ts = (new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US)).format(new Date()); return ".DT" + ts + ".xxx"; } }//LAST
Tidak ada komentar:
Posting Komentar