Created
February 7, 2017 21:29
-
-
Save Domacoski/e0b835f267538faf65e231f130f87fa2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signingConfigs { | |
deployer { | |
keyAlias KEY_ALIAS | |
keyPassword KEY_PASSWORD | |
storeFile file(STORE_FILE) | |
storePassword STORE_PASSWORD | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tl.domacoski.myapplication; | |
import android.util.Base64; | |
import java.io.UnsupportedEncodingException; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.Arrays; | |
import javax.crypto.Cipher; | |
import javax.crypto.spec.SecretKeySpec; | |
/** | |
* Created by thiago.domacoski on 07/02/17. | |
*/ | |
public class Crypto { | |
private static SecretKeySpec secretKey; | |
private static byte[] key; | |
public static void setKey(String myKey) | |
{ | |
MessageDigest sha = null; | |
try { | |
key = myKey.getBytes("UTF-8"); | |
sha = MessageDigest.getInstance("SHA-1"); | |
key = sha.digest(key); | |
key = Arrays.copyOf(key, 16); | |
secretKey = new SecretKeySpec(key, "AES"); | |
} | |
catch (NoSuchAlgorithmException e) { | |
e.printStackTrace(); | |
} | |
catch (UnsupportedEncodingException e) { | |
e.printStackTrace(); | |
} | |
} | |
public static String encrypt(String strToEncrypt, String secret) | |
{ | |
try | |
{ | |
setKey(secret); | |
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); | |
cipher.init(Cipher.ENCRYPT_MODE, secretKey); | |
return Base64.encodeToString(cipher.doFinal(strToEncrypt.getBytes("UTF-8")), Base64.DEFAULT) ; | |
} | |
catch (Exception e) | |
{ | |
System.out.println("Error while encrypting: " + e.toString()); | |
} | |
return null; | |
} | |
public static String decrypt(String strToDecrypt, String secret) | |
{ | |
try | |
{ | |
setKey(secret); | |
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); | |
cipher.init(Cipher.DECRYPT_MODE, secretKey); | |
return new String(cipher.doFinal(Base64.decode(strToDecrypt, Base64.DEFAULT) ) ); | |
} | |
catch (Exception e) | |
{ | |
System.out.println("Error while decrypting: " + e.toString()); | |
} | |
return null; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-dontpreverify | |
#-repackageclasses 'com.sulamerica.ceabs.ubimobile' | |
-repackageclasses 'android' | |
-allowaccessmodification | |
-keepattributes *Annotation*,Signature | |
-optimizationpasses 10 | |
-printmapping build/outputs/mapping/release/proguard-mapping.txt | |
-keep class * extends android.app.Activity | |
-keep class * extends com.sulamerica.ceabs.ubimobile.MainActivity | |
-keep class * extends android.app.Application | |
-keep class * extends android.app.Service | |
-keep class * extends android.content.BroadcastReceiver | |
-keep class * extends android.app.IntentService | |
-keep class * extends android.content.ContentProvider | |
-keep class * extends com.ceabs.library.okhttpmodel.JsonModel | |
-keep class * extends com.sulamerica.ceabs.ubimobile.utils.BaseJson | |
-keepclassmembers class * implements android.os.Parcelable { | |
static ** CREATOR; | |
} | |
-keepclassmembers class **.R$* { | |
public static <fields>; | |
} | |
-keepclassmembers public class * { | |
@com.google.gson.annotations.SerializedName *; | |
} | |
-keep @com.google.gson.annotations.SerializedName public class * | |
-keep public class * extends android.view.View { | |
public <init>(android.content.Context); | |
public <init>(android.content.Context, android.util.AttributeSet); | |
public <init>(android.content.Context, android.util.AttributeSet, int); | |
public void set*(...); | |
} | |
-keepclasseswithmembers class * { | |
public <init>(android.content.Context, android.util.AttributeSet); | |
} | |
-keepclasseswithmembers class * { | |
public <init>(android.content.Context, android.util.AttributeSet, int); | |
} | |
-keepclassmembers class * extends android.content.Context { | |
public void *(android.view.View); | |
public void *(android.view.MenuItem); | |
} | |
-keepclasseswithmembernames class * extends com.ceabs.library.okhttpmodel.OkHttpModel{ | |
public <methods> ; | |
private <fields> ; | |
} | |
-keep class com.sulamerica.ceabs.ubimobile.recognized.UpdateReconized{ | |
public <methods> ; | |
private <fields> ; | |
public static <fields> ; | |
} | |
-keep class com.sulamerica.ceabs.ubimobile.utils.SharedPreferencesModel{ | |
public <methods> ; | |
private <fields> ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment