@@ -30,57 +30,111 @@ protected void onCreate(Bundle savedInstanceState) {
3030 super .onCreate (savedInstanceState );
3131 setContentView (R .layout .activity_main );
3232
33- ConcealPrefRepository .applicationInit (getApplication (), false );
33+ ConcealPrefRepository .applicationInit (getApplication ());
3434
35+ concealPrefRepository .clearPrefs ();
36+
37+
38+ //FIRST TEST
39+ concealPrefRepository .putString (NAME_KEY , "HAFIQ IQMAL" );
40+ concealPrefRepository .putInt (AGE_KEY , 24 );
41+
42+ Log .d ("FIRST TEST" , concealPrefRepository .getString (NAME_KEY ));
43+ Log .d ("FIRST TEST" ,concealPrefRepository .getString (AGE_KEY ));
44+ Log .d ("FIRST TEST SIZE" , "" +concealPrefRepository .getPrefsSize ());
45+
46+ concealPrefRepository .clearPrefs ();
47+
48+ //SECOND TEST
3549 new ConcealPrefRepository .Editor ()
3650 .putString (NAME_KEY , "Hafiq Iqmal" )
3751 .putInt (AGE_KEY , 24 )
3852 .
putString (
EMAIL_KEY ,
"[email protected] " )
3953 .apply ();
4054
55+ Log .d ("SECOND TEST" , concealPrefRepository .getString (NAME_KEY ));
56+ Log .d ("SECOND TEST" ,concealPrefRepository .getString (AGE_KEY ));
57+ Log .d ("SECOND TEST SIZE" , "" +concealPrefRepository .getPrefsSize ());
58+
59+
60+
61+ concealPrefRepository .clearPrefs ();
4162
4263 //add user details preferences
4364 new ConcealPrefRepository .
UserPref (
"PREFIX" ).
setFirstName (
"Firstname" ).
setLastName (
"Lasname" ).
setEmail (
"[email protected] " ).
apply ();
4465
4566 //get user details
46- Log .d ("TAG" ,new ConcealPrefRepository .UserPref ("PREFIX" ).getFirstName ());
47- Log .d ("TAG" ,new ConcealPrefRepository .UserPref ().setDefault ("No Data" ).getLastName ());
48- Log .d ("TAG" ,new ConcealPrefRepository .UserPref ().setDefault ("No Data" ).getEmail ());
49-
50-
51- // Map<String,String> map =concealPrefRepository.getAllSharedPrefData();
52- // for(Map.Entry<String,?> entry : map.entrySet()){
53- // try {
54- // Log.d("TAG",entry.getKey()+" :: "+entry.getValue().toString());
55- // }
56- // catch (Exception e){
57- // e.printStackTrace();
58- // }
59- // }
60- //
61- // List<CryptoFile> cryptoFileList = concealPrefRepository.getAllConcealEncryptedFiles();
62- // for (CryptoFile cryptoFile :cryptoFileList){
63- // Log.d("TAG",cryptoFile.getFileName());
64- // }
65- //
66- // Log.d("TAG",""+concealPrefRepository.getPrefsSize());
67- //
68- // ConcealCrypto concealCrypto = new ConcealCrypto.CryptoBuilder(this)
69- // .setEnableCrypto(true) //default true
70- // .setKeyChain(CryptoConfig.KEY_256) // CryptoConfig.KEY_256 or CryptoConfig.KEY_128
71- // .createPassword("Mac OSX")
72- // .create();
73- //
74- // String test = "Hello World";
75- // String cipher = concealCrypto.obscure(test); //encrypt
76- // Log.d("Display", cipher);
77- // String dec = concealCrypto.deObscure(cipher); //decrypt
78- // Log.d("Display", cipher+" ===== "+dec);
79- //
80- //
81- // cipher = concealCrypto.obscureWithIteration(test,4); //encrypt with 4 times
82- // Log.d("Display", cipher);
83- // dec = concealCrypto.deObscureWithIteration(cipher,3); //decrypt with 4 times
84- // Log.d("Display", cipher+" ===== "+dec);
67+ Log .d ("THIRD_TEST" ,new ConcealPrefRepository .UserPref ("PREFIX" ).getFirstName ());
68+ Log .d ("THIRD_TEST" ,new ConcealPrefRepository .UserPref ().setDefault ("No Data" ).getLastName ());
69+ Log .d ("THIRD_TEST" ,new ConcealPrefRepository .UserPref ("PREFIX" ).setDefault ("No Data" ).getEmail ());
70+ Log .d ("THIRD_TEST TEST SIZE" , "" +concealPrefRepository .getPrefsSize ());
71+
72+
73+
74+ concealPrefRepository .clearPrefs ();
75+
76+
77+ ConcealPrefRepository .UserPref userPref = new ConcealPrefRepository .UserPref ("PREFIX" , "No Data" );
78+ userPref .setUserName ("afiqiqmal" );
79+ userPref .
setEmail (
"[email protected] " );
80+ userPref .apply ();
81+
82+
83+ //get user details
84+ Log .d ("FOURTH_TEST" ,userPref .getUserName ());
85+ Log .d ("FOURTH_TEST" ,userPref .getEmail ());
86+
87+
88+
89+ ConcealPrefRepository .DevicePref devicePref = new ConcealPrefRepository .DevicePref ("PREFIX" , "No Data" );
90+ devicePref .setDeviceId ("ABC123123123" );
91+ devicePref .setDeviceOS ("android" );
92+ devicePref .apply ();
93+
94+
95+ //get user details
96+ Log .d ("FIFTH_TEST" ,devicePref .getDeviceId ());
97+ Log .d ("FIFTH_TEST" ,devicePref .getDeviceOs ());
98+
99+
100+
101+ Map <String ,String > map =concealPrefRepository .getAllSharedPrefData ();
102+ for (Map .Entry <String ,?> entry : map .entrySet ()){
103+ try {
104+ Log .d ("VIEW_ALL" ,entry .getKey ()+" :: " +entry .getValue ().toString ());
105+ }
106+ catch (Exception e ){
107+ e .printStackTrace ();
108+ }
109+ }
110+ Log .d ("VIEW ALL SIZE" , "" +concealPrefRepository .getPrefsSize ());
111+
112+
113+ ConcealCrypto concealCrypto = new ConcealCrypto .CryptoBuilder (this )
114+ .setEnableCrypto (true ) //default true
115+ .setKeyChain (CryptoConfig .KEY_256 ) // CryptoConfig.KEY_256 or CryptoConfig.KEY_128
116+ .createPassword ("Mac OSX" )
117+ .create ();
118+
119+ String test = "Hello World" ;
120+ String cipher = concealCrypto .obscure (test ); //encrypt
121+ Log .d ("CYRPTO TEST E" , cipher );
122+ String dec = concealCrypto .deObscure (cipher ); //decrypt
123+ Log .d ("CYRPTO TEST D" , dec );
124+
125+ test = "Hello World Iteration" ;
126+ cipher = concealCrypto .obscureWithIteration (test ,4 ); //encrypt with 4 times
127+ Log .d ("CYRPTO TEST E" , cipher );
128+ dec = concealCrypto .deObscureWithIteration (cipher ,4 ); //decrypt with 4 times
129+ Log .d ("CYRPTO TEST D" , dec );
130+
131+
132+
133+ cipher = concealCrypto .aesEncrypt ("Hello World is World Hello Aes Cryption" );
134+ Log .d ("AES E" , cipher );
135+ dec = concealCrypto .aesDecrypt (cipher );
136+ Log .d ("AES D" , dec );
137+
138+
85139 }
86140}
0 commit comments