1616
1717public class SettingsActivity extends ImisActivity {
1818
19- Button btnSaveRarPwd , btnDefaultRarPassword ;
20- EditText etRarPassword ;
19+ Button btnSaveZipPwd , btnDefaultZipPassword ;
20+ EditText etZipPassword ;
2121 private String salt , password ;
2222 public static String generatedSalt ;
23- Global global ;
2423
2524 @ Override
2625 protected void onCreate (Bundle savedInstanceState ) {
@@ -29,27 +28,27 @@ protected void onCreate(Bundle savedInstanceState) {
2928
3029 actionBar .setTitle ("Settings" );
3130
32- btnSaveRarPwd = (Button )findViewById (R .id .btnSaveRarPwd );
33- etRarPassword = (EditText )findViewById (R .id .rarPassword );
34- btnDefaultRarPassword = (Button ) findViewById (R .id .btnDefaultRarPassword );
31+ btnSaveZipPwd = (Button )findViewById (R .id .btnSaveZipPwd );
32+ etZipPassword = (EditText )findViewById (R .id .zipPassword );
33+ btnDefaultZipPassword = (Button ) findViewById (R .id .btnDefaultZipPassword );
3534
36- btnSaveRarPwd .setOnClickListener (view -> {
37- if (etRarPassword .getText ().length () == 0 ){
38- ShowDialog ("Rar password required" );
35+ btnSaveZipPwd .setOnClickListener (view -> {
36+ if (etZipPassword .getText ().length () == 0 ){
37+ ShowDialog ("Zip password required" );
3938 }
4039 else {
41- password = etRarPassword .getText ().toString ();
42- saveRarPassword (password );
40+ password = etZipPassword .getText ().toString ();
41+ saveZipPassword (password );
4342 ShowDialog ("Password has been changed" );
44- etRarPassword .setText ("" );
43+ etZipPassword .setText ("" );
4544 }
4645
4746 });
4847
49- btnDefaultRarPassword .setOnClickListener (view -> {
50- password = global .getDefaultRarPassword ();
51- saveRarPassword (password );
52- ShowDialog ("Password has been changed to the default rar password" );
48+ btnDefaultZipPassword .setOnClickListener (view -> {
49+ password = global .getDefaultZipPassword ();
50+ saveZipPassword (password );
51+ ShowDialog ("Password has been changed to the default zip password" );
5352 });
5453
5554 }
@@ -67,7 +66,7 @@ private SecretKeySpec generateKey(String encPassword) throws Exception {
6766 return secretKeySpec ;
6867 }
6968
70- public String encryptRarPwd (String dataToEncrypt , String encPassword ) throws Exception {
69+ public String encryptZipPwd (String dataToEncrypt , String encPassword ) throws Exception {
7170 SecretKeySpec key = generateKey (encPassword );
7271 Cipher c = Cipher .getInstance ("AES" );
7372 c .init (Cipher .ENCRYPT_MODE , key );
@@ -76,7 +75,7 @@ public String encryptRarPwd(String dataToEncrypt, String encPassword) throws Exc
7675 return encryptedValue ;
7776 }
7877
79- public String decryptRarPwd (String dataToDecrypt , String decPassword ) throws Exception {
78+ public String decryptZipPwd (String dataToDecrypt , String decPassword ) throws Exception {
8079 SecretKeySpec key = generateKey (decPassword );
8180 Cipher c = Cipher .getInstance ("AES" );
8281 c .init (Cipher .DECRYPT_MODE , key );
@@ -96,15 +95,15 @@ public String generateSalt(){
9695 return encodedSalt ;
9796 }
9897
99- public void saveRarPassword (String password ){
98+ public void saveZipPassword (String password ){
10099 try {
101100 SharedPreferences sharedPreferences = global .getDefaultSharedPreferences ();
102101 SharedPreferences .Editor editor = sharedPreferences .edit ();
103102 salt = generateSalt ();
104103 String trimSalt = salt .trim ();
105- String encryptedPassword = encryptRarPwd (password , trimSalt );
104+ String encryptedPassword = encryptZipPwd (password , trimSalt );
106105 String trimEncryptedPassword = encryptedPassword .trim ();
107- editor .putString ("rarPwd " , trimEncryptedPassword );
106+ editor .putString ("zipPwd " , trimEncryptedPassword );
108107 editor .putString ("salt" , trimSalt );
109108 editor .apply ();
110109 }
0 commit comments