Skip to content

Commit 7766ce2

Browse files
author
Muralidharan Ramasamy
committed
2.04 version
1 parent b802cf3 commit 7766ce2

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,59 @@ store token in global variable for other user
3434
Generate envrypted token as mentioned below using below coding (AES 256 cryptography encryption)
3535
Once plugin receives this token, it will unencrypt using the secret key generate and compare hash code to confirm it is sent from mobile app
3636

37+
Firebase httpv1 version requires separate intent filter, please use intent filter for mainactivity like below
38+
39+
'''XML
40+
<activity
41+
android:name=".MainActivity"
42+
android:exported="true">
43+
<intent-filter>
44+
<action android:name="android.intent.action.MAIN" />
45+
<category android:name="android.intent.category.LAUNCHER" />
46+
</intent-filter>
47+
<intent-filter>
48+
<action android:name="OPEN_MAIN_ACTIVITY" />
49+
<category android:name="android.intent.category.DEFAULT" />
50+
</intent-filter>
51+
</activity>
52+
'''
53+
Following is optional, Google requires encryption needs to be AES/GCM/NoPadding, Following is updated encryption logic using AES/GCM/NoPadding, at present plugin works for both old encryption method (AES/CBC/PKCS5Padding) as well as for new method AES/GCM/NoPadding.
54+
55+
Following is example code encryption using AES/GCM/NoPadding to connect to PNFPB plugin REST API
56+
57+
'''JAVA
58+
/*** NEW method of encrypting using AES GCM Nopadding - 2024 */
59+
SecureRandom secureRandom = new SecureRandom();
60+
byte[] iv = new byte[16]; // GCM mode typically uses a 12-byte IV
61+
secureRandom.nextBytes(iv);
62+
IvParameterSpec ivSpec = new IvParameterSpec(iv);
63+
// Create an AES key from the secret
64+
SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(), "AES");
65+
// Initialize Cipher in AES/GCM/NoPadding mode
66+
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
67+
cipher.init(Cipher.ENCRYPT_MODE, secretKey, new GCMParameterSpec(128, iv));
68+
// Encrypt the token
69+
byte[] encryptedToken = cipher.doFinal(token.getBytes("UTF-8"));
70+
String finalresultstring = Base64.encodeToString(encryptedToken, Base64.NO_WRAP);
71+
String ivString = Base64.encodeToString(iv, Base64.NO_WRAP);
72+
// HMAC calculation for integrity check (if needed)
73+
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
74+
sha256_HMAC.init(new SecretKeySpec(secret.getBytes(), "HmacSHA256"));
75+
byte[] hmacBytes = sha256_HMAC.doFinal(token.getBytes("UTF-8"));
76+
StringBuilder byteContent = new StringBuilder();
77+
for (byte b : hmacBytes)
78+
{
79+
byteContent.append(String.format("%02x", b));
80+
}
81+
POST_PARAMS = finalresultstring + ":" + ivstring + ":" + byteContent + ":" + byteContent;
82+
postRequest(POST_PARAMS);
83+
WebSettings settings = mywebView.getSettings();
84+
'''
85+
86+
3787
# Video tutorial showing how to configure Firebase for this plugin<br />
88+
89+
https://youtu.be/T07qpqao_-E?si=LX1pAl1ZHCiyn4Fi <br/>
3890

3991
https://www.youtube.com/watch?v=02oymYLt3qo <br />
4092

0 commit comments

Comments
 (0)