rockaport / alice Goto Github PK
View Code? Open in Web Editor NEWJava AES encryption library
Home Page: https://rockaport.github.io/alice/
License: Apache License 2.0
Java AES encryption library
Home Page: https://rockaport.github.io/alice/
License: Apache License 2.0
Hi @rockaport thanks for this library.
I got this error log SecretKeyFactory PBKDF2WithHmacSHA512 implementation not found
Any work-around for it?
Thanks in anticipation.
Hi, can you help me pls because the lib works only with min android 8 and I need to work with min android 6
In the meantime exclude it when adding Alice as a dependency
implementation('com.github.rockaport:alice:0.9.0') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
Hi guys, I'm following the tutorial, and here is my code
Alice alice = new Alice(new AliceContextBuilder().build());
byte[] encryptedBytes = alice.encrypt("hello".getBytes(), "password".toCharArray());
However I got this error message. ?
java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.implInit(Cipher.java:805)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)
at com.rockaport.alice.Alice.encrypt(Alice.java:177)
at com.netobjex.ubc.service.IPFSServiceTest.setup(IPFSServiceTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
KeySpec ks = new PBEKeySpec(mnemonic, salt, 2048, 512);
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512");
return skf.generateSecret(ks).getEncoded();
Hey @rockaport, what might this code look like using alice?
Hi,
I want to use your library in a project of mine and I need to get the encrypted output as a string with UTF-8 format. Is that possible?
I use that:
AliceContext aliceContext = new AliceContextBuilder() .setAlgorithm(AliceContext.Algorithm.AES) .setMode(AliceContext.Mode.CBC) // or AliceContext.Mode.CTR .setIvLength(16) .setPadding(AliceContext.Padding.PKCS5_PADDING) .setPbkdf(AliceContext.Pbkdf.PBKDF_2_WITH_HMAC_SHA_512) .setMacAlgorithm(AliceContext.MacAlgorithm.HMAC_SHA_512) .build();
And to get the output I use that:
byte[] d = alice.encrypt(toEncrypt.getBytes(), secretKey.toCharArray()); System.out.println(new String(d)); System.out.println(new String(alice.decrypt(d, secretKey.toCharArray())));
But the output looks like:
�8Ӥ�Öz�>�$����B�+4�\kLA{�R�a Bŋ����֒b�\ا� �]j�.���?�r�$j"RɫIܪ���C��>p���~�L�]��������\��R3;!p�.��T������Ѫ&�r ��TK<{>A�HN�?�07�nϳ�U�ؑ�<X������j�����YA<K�dы�BP+9�
Do you have an idea to get an output that is sharable?
You literally only use it in one place and it is EASILY replaced with a ByteArrayOutputStream.
I rewrote your the last part of your encrypt() method to not use any dependencies:
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
output.write(cipher.getIV());
output.write(encryptedBytes);
// compute the MAC if needed and append the MAC (IV || CIPHER || MAC)
if (context.getMacAlgorithm() != AliceContext.MacAlgorithm.NONE) {
output.write(getMac(context.getMacAlgorithm(), password).doFinal(encryptedBytes));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return output.toByteArray();
Having it added in gradle,on run the following error is given:
`Information:Gradle tasks [:app:assembleDebug]
Warning:Ignoring InnerClasses attribute for an anonymous inner class
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/nimashahbazi/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.1/a9ca9c9de09361ec2a18d2c058d2524fbd8eae0c/groovy-all-2.4.1.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing org/codehaus/groovy/vmplugin/v7/IndyInterface.class
Error:com.android.dx.cf.code.SimException: signature-polymorphic method called without --min-sdk-version >= 26
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/nimashahbazi/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.1/a9ca9c9de09361ec2a18d2c058d2524fbd8eae0c/groovy-all-2.4.1.jar
Information:BUILD FAILED in 10s
Information:4 errors
Information:1 warning
Information:See complete output in console`
Any ideas? Thanks
when i encrypt the Persian characters and decrypt, result is half of original string!
original string :
plainText = "سلام امیر";
result string :
سلام
I have been trying to encrypt a zip file using different algorithms presented in the library. The file is encrypted and decrypted and when I try to to unzip it, seems like the file is corrupted...
I have tried many compression tools and seems like this is happening because of the encryption process. Have you ever faced anything like that and any ideas on what needs to be done?
When I add the following line to gradle
implementation 'com.github.rockaport:alice:0.9.0'
and building the project , I encounter the following error
Error: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26).
what is the problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.