Encrypt
Encrypt copied to clipboard
关于您【加密你的App】一文的疑问
Hi,
冒昧了,作为primary engineer的我,看了您的这篇blog,有点疑问:
①因为没做过jni开发,看得不太明白cpp中的内容,按我的理解,加密必须要有一个keychain,请问keychain是在何处生成的呢?
②克隆了您的git项目后打开运行,报了以下错误:
01-01 00:58:58.102 5412-5412/net.robinx.encrypt E/AndroidRuntime: FATAL EXCEPTION: main Process: net.robinx.encrypt, PID: 5412 java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String net.robinx.lib.encrypt.SecretKeyHelper.createSecretKey(android.content.Context) (tried Java_net_robinx_lib_encrypt_SecretKeyHelper_createSecretKey and Java_net_robinx_lib_encrypt_SecretKeyHelper_createSecretKey__Landroid_content_Context_2) at net.robinx.lib.encrypt.SecretKeyHelper.createSecretKey(Native Method) at net.robinx.lib.encrypt.SecretKeyHelper.getSecretKey(SecretKeyHelper.java:12) at net.robinx.lib.encrypt.conceal.ConcealHelper.init(ConcealHelper.java:50) at net.robinx.encrypt.MainApplication.onCreate(MainApplication.java:16) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1018) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4970) at android.app.ActivityThread.-wrap1(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1560) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5765) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 01-01 00:59:08.737 880-914/system_process E/MultiWindowProxy: getServiceInstance failed!
还望不吝赐教,谢谢!
Best regards, Jelansty Lee
NDK没有正确编译,调用Conceal主要是获得一个自己创建的key,至于keychain已经有写好的SharedPrefsBackedKeyChain,通过keychain获得Crypto对象,通过Crypto对象实现加解密,加密的同时需要一个根据key生成的Entity,流程如下,此库主要针对key的获取过程,使用jni的方式相对提升安全性,当然你实在有困难,可自己修改下key的获取方式,根据一套算法,构造出key,那也是可以得
SharedPrefsBackedKeyChain msp = new SharedPrefsBackedKeyChain(context, CryptoConfig.KEY_256);
Crypto crypto = AndroidConceal.get().createDefaultCrypto(msp);
String secretKey = SecretKeyHelper.getSecretKey(context);
Entity entity = Entity.create(secretKey);
crypto .encrypt(plainBytes, mEntity);