Commit 27bb3169 authored by Corentin Mors's avatar Corentin Mors
Browse files

Add new icon + change crypto with random IV

parent 757f0257
......@@ -3,6 +3,11 @@
<component name="WizardSettings">
<option name="children">
<map>
<entry key="imageWizard">
<value>
<PersistentState />
</value>
</entry>
<entry key="vectorWizard">
<value>
<PersistentState>
......
......@@ -15,7 +15,6 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
......
......@@ -9,6 +9,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.constraint.Placeholder;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
......@@ -28,6 +29,7 @@ import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.List;
......@@ -49,6 +51,7 @@ public class ChatFragment extends Fragment {
private RecyclerView mMessagesView;
private EditText mInputMessageView;
private TextView PlaceholderNumUsers;
private List<Message> mMessages = new ArrayList<Message>();
private RecyclerView.Adapter mAdapter;
private boolean mTyping = false;
......@@ -133,11 +136,12 @@ public class ChatFragment extends Fragment {
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mMessagesView = (RecyclerView) view.findViewById(R.id.messages);
mMessagesView = view.findViewById(R.id.messages);
mMessagesView.setLayoutManager(new LinearLayoutManager(getActivity()));
mMessagesView.setAdapter(mAdapter);
mInputMessageView = (EditText) view.findViewById(R.id.message_input);
mInputMessageView = view.findViewById(R.id.message_input);
mInputMessageView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int id, KeyEvent event) {
......@@ -256,6 +260,12 @@ public class ChatFragment extends Fragment {
startSignIn();
}
private void updateUserNumber(int number){
View view = getActivity().findViewById(R.id.dragView);
PlaceholderNumUsers = view.findViewById(R.id.chat_slider_text);
PlaceholderNumUsers.setText(number + " participants in channel " + mRoom);
}
private void scrollToBottom() {
mMessagesView.scrollToPosition(mAdapter.getItemCount() - 1);
}
......@@ -356,6 +366,7 @@ public class ChatFragment extends Fragment {
addLog(getResources().getString(R.string.message_user_joined, username));
addParticipantsLog(numUsers);
updateUserNumber(numUsers);
}
});
}
......@@ -381,7 +392,7 @@ public class ChatFragment extends Fragment {
addLog(getResources().getString(R.string.message_user_left, username));
addParticipantsLog(numUsers);
removeTyping(username);
updateUserNumber(numUsers);
}
});
}
......@@ -400,11 +411,12 @@ public class ChatFragment extends Fragment {
int numUsers;
try {
numUsers = data.getInt("numUsers");
addParticipantsLog(numUsers);
} catch (JSONException e) {
Log.e("OM_LOG", "Fail num user");
return;
}
addParticipantsLog(numUsers);
updateUserNumber(numUsers);
}
});
}
......
......@@ -4,14 +4,12 @@ public class CryptoFunc {
public static String sencrypt(String password, String data) throws Exception {
CryptLib cryptLib = new CryptLib();
String iv = "1234123412341234";
return cryptLib.encryptPlainText(data, password, iv);
return cryptLib.encryptPlainTextWithRandomIV(data, password);
}
public static String sdecrypt(String password, String data) throws Exception {
CryptLib cryptLib = new CryptLib();
String iv = "1234123412341234";
return cryptLib.decryptCipherText(data, password, iv);
return cryptLib.decryptCipherTextWithRandomIV(data, password);
}
}
......@@ -37,7 +37,7 @@
android:orientation="horizontal">
<TextView
android:id="@+id/name"
android:id="@+id/chat_slider_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
......
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
......@@ -2375,12 +2375,11 @@ function config (name) {
// Crypto functions
 
var cryptoLib = require('@skavinvarnan/cryptlib');
var iv = "1234123412341234";
 
window.encrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
return cryptoLib.encrypt(data, shaKey, iv);
return cryptoLib.encryptPlainTextWithRandomIV(data, shaKey);
} catch (exception) {
throw new Error(exception.message);
}
......@@ -2389,7 +2388,7 @@ window.encrypt = function (data, password){
window.decrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
return cryptoLib.decrypt(data, shaKey, iv);
return cryptoLib.decryptCipherTextWithRandomIV(data, shaKey);
} catch (exception) {
throw new Error(exception.message);
}
......@@ -2398,7 +2397,7 @@ window.decrypt = function (data, password){
window.oencrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
return cryptoLib.encrypt(JSON.stringify(data), shaKey, iv);
return cryptoLib.encryptPlainTextWithRandomIV(JSON.stringify(data), shaKey);
} catch (exception) {
throw new Error(exception.message);
}
......@@ -2407,7 +2406,7 @@ window.oencrypt = function (data, password){
window.odecrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
var ostring = cryptoLib.decrypt(data, shaKey, iv);
var ostring = cryptoLib.decryptCipherTextWithRandomIV(data, shaKey);
return JSON.parse(ostring);
} catch (exception) {
throw new Error(exception.message);
......
// Crypto functions
var cryptoLib = require('@skavinvarnan/cryptlib');
var iv = "1234123412341234";
window.encrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
return cryptoLib.encrypt(data, shaKey, iv);
return cryptoLib.encryptPlainTextWithRandomIV(data, shaKey);
} catch (exception) {
throw new Error(exception.message);
}
......@@ -15,7 +14,7 @@ window.encrypt = function (data, password){
window.decrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
return cryptoLib.decrypt(data, shaKey, iv);
return cryptoLib.decryptCipherTextWithRandomIV(data, shaKey);
} catch (exception) {
throw new Error(exception.message);
}
......@@ -24,7 +23,7 @@ window.decrypt = function (data, password){
window.oencrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
return cryptoLib.encrypt(JSON.stringify(data), shaKey, iv);
return cryptoLib.encryptPlainTextWithRandomIV(JSON.stringify(data), shaKey);
} catch (exception) {
throw new Error(exception.message);
}
......@@ -33,7 +32,7 @@ window.oencrypt = function (data, password){
window.odecrypt = function (data, password){
try {
shaKey = cryptoLib.getHashSha256(password, 32);
var ostring = cryptoLib.decrypt(data, shaKey, iv);
var ostring = cryptoLib.decryptCipherTextWithRandomIV(data, shaKey);
return JSON.parse(ostring);
} catch (exception) {
throw new Error(exception.message);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment