From 6fe3778febf85c0d58e3e6aa536ef0baa89f4412 Mon Sep 17 00:00:00 2001
From: M66B
Date: Mon, 17 Oct 2022 12:31:02 +0200
Subject: [PATCH] Added protect text FAQ
---
FAQ.md | 20 ++++++++++++++++-
.../java/eu/faircode/email/StyleHelper.java | 22 +++++++++++++++++--
.../res/layout/dialog_password_protect.xml | 13 ++++++-----
app/src/main/res/menu/popup_style.xml | 2 +-
app/src/main/res/values/strings.xml | 4 ++--
decrypt/index.html | 13 ++++++-----
6 files changed, 56 insertions(+), 18 deletions(-)
diff --git a/FAQ.md b/FAQ.md
index 5e46c9d5ff..637ad4675c 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -393,6 +393,7 @@ Fonts, sizes, colors, etc should be material design whenever possible.
* [(181) How do I use VirusTotal?](#user-content-faq181)
* [(182) How can I select how a link should be opened?](#user-content-faq182)
* [(183) How do I use Send?](#user-content-faq183)
+* [(184) How do I password protect text?](#user-content-faq184)
[I have another question.](#user-content-get-support)
@@ -4982,6 +4983,23 @@ Send is only available in non-Play Store versions of the app (since version 1.19
+
+**(184) How do I password protect text?**
+
+Select some text by long pressing it, and in the style toolbar at the bottom tap on the *A*-button and select *Password protect* in the pop-up menu.
+
+Password protected text is sent as a [URI fragment](https://en.wikipedia.org/wiki/URI_fragment) and not stored on a server, and decrypted in the browser with JavaScript.
+
+Password protected text is encrypted with AES/GCM with a 256 bits key derived with PBKDF2/SHA-512 with 120,000 iterations.
+
+The maximum message text is 1,500 characters, which includes HTML formatting tags.
+
+This feature is not available in the Play store version of the app.
+
+Sending protected text is a pro feature, decrypting protected text is a free feature.
+
+
+
Get support
🌎 [Google Translate](https://translate.google.com/translate?sl=en&u=https://github.com/M66B/FairEmail/blob/master/FAQ.md%23user-content-get-support)
@@ -5033,4 +5051,4 @@ GitHub issues are disabled due to frequent misusage.
-Copyright © 2018-2021 Marcel Bokhorst.
+Copyright © 2018-2022 Marcel Bokhorst.
diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java
index 15c64f1c84..b368095a61 100644
--- a/app/src/main/java/eu/faircode/email/StyleHelper.java
+++ b/app/src/main/java/eu/faircode/email/StyleHelper.java
@@ -56,6 +56,7 @@ import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.WindowManager;
+import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@@ -88,6 +89,8 @@ import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.PBEKeySpec;
public class StyleHelper {
+ private static final int MAX_PROTECTED_TEXT = 1500;
+
private static final List CLEAR_STYLES = Collections.unmodifiableList(Arrays.asList(
StyleSpan.class,
UnderlineSpan.class,
@@ -573,6 +576,14 @@ public class StyleHelper {
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_password_protect, null);
TextInputLayout etPassword1 = dview.findViewById(R.id.tilPassword1);
TextInputLayout etPassword2 = dview.findViewById(R.id.tilPassword2);
+ Button btnInfo = dview.findViewById(R.id.btnInfo);
+
+ btnInfo.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Helper.viewFAQ(v.getContext(), 184);
+ }
+ });
Dialog dialog = new AlertDialog.Builder(context)
.setView(dview)
@@ -606,6 +617,9 @@ public class StyleHelper {
String password = args.getString("password");
String html = HtmlHelper.toHtml(text, context);
+ if (html.length() > MAX_PROTECTED_TEXT)
+ throw new IllegalArgumentException(context.getString(R.string.title_style_protect_size));
+
SecureRandom random = new SecureRandom();
byte[] salt = new byte[16]; // 128 bits
@@ -655,8 +669,12 @@ public class StyleHelper {
@Override
protected void onException(Bundle args, Throwable ex) {
- Log.e(ex);
- ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
+ if (ex instanceof IllegalArgumentException)
+ ToastEx.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
+ else {
+ Log.e(ex);
+ ToastEx.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
+ }
}
}.execute(context, owner, args, "protect");
}
diff --git a/app/src/main/res/layout/dialog_password_protect.xml b/app/src/main/res/layout/dialog_password_protect.xml
index 1064854508..7cc85c6173 100644
--- a/app/src/main/res/layout/dialog_password_protect.xml
+++ b/app/src/main/res/layout/dialog_password_protect.xml
@@ -17,7 +17,7 @@
android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_lock_24"
android:drawablePadding="6dp"
- android:text="@string/title_style_password"
+ android:text="@string/title_style_protect"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -64,14 +64,15 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
-
diff --git a/app/src/main/res/menu/popup_style.xml b/app/src/main/res/menu/popup_style.xml
index 7ebe5112e7..4c649eaa79 100644
--- a/app/src/main/res/menu/popup_style.xml
+++ b/app/src/main/res/menu/popup_style.xml
@@ -183,7 +183,7 @@
+ android:title="@string/title_style_protect" />
Superscript
Strikethrough
Code
- Password protect
- AES/GCM 256 bit PBKDF2/SHA-256/120,000
+ Password protect
+ Text too long
Clear formatting
Insert link
Address
diff --git a/decrypt/index.html b/decrypt/index.html
index 0d2da93329..3dec57ca64 100644
--- a/decrypt/index.html
+++ b/decrypt/index.html
@@ -2,11 +2,11 @@
- Decrypt message
+ Decrypt text
-
+
@@ -116,11 +116,11 @@
- Messages are sent as a URI fragment and not stored on a server, and decrypted in the browser with JavaScript.
- Messages are encrypted with AES/GCM with a 256 bits key derived with PBKDF2/SHA-512/120,000 iterations.
+ Password protected text is sent as a URI fragment and not stored on a server, and decrypted in the browser with JavaScript.
+ Password protected text is encrypted with AES/GCM with a 256 bits key derived with PBKDF2/SHA-512 with 120,000 iterations.
+ Please see here for more information.