From 3ca7d9b369fd0419318a0ee412ed16087ed02473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patric=20Karlstr=C3=B6m?= Date: Wed, 13 Jan 2021 15:33:31 +0100 Subject: [PATCH] Use StandardCharsets.UTF_8 instead of string UTF8 --- app/src/main/java/io/lbry/browser/MainActivity.java | 3 ++- app/src/main/java/io/lbry/browser/utils/Lbryio.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index c113c707..4947efc5 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -121,6 +121,7 @@ import java.io.InputStreamReader; import java.io.PrintStream; import java.net.ConnectException; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; @@ -1799,7 +1800,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener if (!Helper.isNullOrEmpty(encryptedAuthToken)) { try { Lbryio.AUTH_TOKEN = new String(Utils.decrypt( - Base64.decode(encryptedAuthToken, Base64.NO_WRAP), this, Lbry.KEYSTORE), "UTF8"); + Base64.decode(encryptedAuthToken, Base64.NO_WRAP), this, Lbry.KEYSTORE), StandardCharsets.UTF_8); } catch (Exception ex) { // pass. A new auth token would have to be generated if the old one cannot be decrypted Log.e(TAG, "Could not decrypt existing auth token.", ex); diff --git a/app/src/main/java/io/lbry/browser/utils/Lbryio.java b/app/src/main/java/io/lbry/browser/utils/Lbryio.java index 68986978..036eb3f4 100644 --- a/app/src/main/java/io/lbry/browser/utils/Lbryio.java +++ b/app/src/main/java/io/lbry/browser/utils/Lbryio.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -304,7 +305,7 @@ public final class Lbryio { private static void broadcastAuthTokenGenerated(Context context) { try { if (context != null) { - String encryptedAuthToken = Utils.encrypt(AUTH_TOKEN.getBytes("UTF8"), context, Lbry.KEYSTORE); + String encryptedAuthToken = Utils.encrypt(AUTH_TOKEN.getBytes(StandardCharsets.UTF_8), context, Lbry.KEYSTORE); Intent intent = new Intent(MainActivity.ACTION_AUTH_TOKEN_GENERATED); intent.putExtra("authToken", encryptedAuthToken); context.sendBroadcast(intent);