+ }
+
+ os.flush();
+ os.close();
+ is.close();
+ }
+
+ public static void xorFile(String filename, String dest, byte[] password, long encryptByteCount) throws IOException {
+ FileInputStream is = new FileInputStream(filename);
+ FileOutputStream os = new FileOutputStream(dest);
+
+ byte[] data = new byte[1024 * 4]; //4 KB buffer
+ int read = is.read(data), index = 0, encryptCnt = 0;
+ while (read != -1) {
+ for (int k = 0; k < read; k++) {
+ if (encryptCnt < encryptByteCount) {
+ data[k] ^= password[index % password.length];
+ index++;
+ encryptCnt++;
+ }
+ }
+ os.write(data, 0, read);
+ read = is.read(data);
+ }
+
+ os.flush();
+ os.close();
+ is.close();
+ }
+
+}
@@ -0,0 +1,32 @@ |
||
| 1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
+ android:layout_width="match_parent" |
|
| 4 |
+ android:layout_height="match_parent" |
|
| 5 |
+ android:background="@color/background_light_grey_color"> |
|
| 6 |
+ |
|
| 7 |
+ <RelativeLayout |
|
| 8 |
+ android:id="@+id/title_layout" |
|
| 9 |
+ android:layout_width="match_parent" |
|
| 10 |
+ android:layout_height="wrap_content" |
|
| 11 |
+ android:background="@color/colorPrimaryDark"> |
|
| 12 |
+ <include layout="@layout/title_bar_with_back_and_option" /> |
|
| 13 |
+ </RelativeLayout> |
|
| 14 |
+ |
|
| 15 |
+ <ImageView |
|
| 16 |
+ android:id="@+id/image_encrypt" |
|
| 17 |
+ android:layout_width="match_parent" |
|
| 18 |
+ android:layout_height="300dp" |
|
| 19 |
+ android:scaleType="centerInside" |
|
| 20 |
+ android:layout_below="@id/title_layout"/> |
|
| 21 |
+ |
|
| 22 |
+ <Button |
|
| 23 |
+ android:id="@+id/btn_encrypt" |
|
| 24 |
+ android:layout_width="100dp" |
|
| 25 |
+ android:layout_height="48dp" |
|
| 26 |
+ android:layout_alignParentBottom="true" |
|
| 27 |
+ android:layout_marginBottom="60dp" |
|
| 28 |
+ android:layout_centerHorizontal="true" |
|
| 29 |
+ android:gravity="center"/> |
|
| 30 |
+ |
|
| 31 |
+ |
|
| 32 |
+</RelativeLayout> |