B4J Question Porting b4a decrypt app to desktop, error java.security

Gnappo jr

Active Member
Licensed User
Longtime User
After a month are at the starting point, see:
https://www.b4x.com/android/forum/threads/help-for-find-library-for-type-cipher.82944/#post-525332
I created a b4a app that sends encrypted strings to a web server in asp.net, everything works fine! I would replace the ASP server with an equivalent B4J server I did but there is only one problem: I can not run a part of the decrypt code in B4J but it works well in B4A,
In B4j Desktop i get the following error:
java.security.NoSuchProviderException: No such provider: BC
Searching on the internet I found this:
https://stackoverflow.com/questions...y-nosuchproviderexception-no-such-provider-bc
but I do not know if it is the solution, overwhelmed to intervene.
I attach the test files: testb4a.zip crypt and successfully decrypt a "test" string
testb4j.zip should decrypt the same string, but it goes wrong.
Thanks to anyone who wants to intervene.
Gnappos
 

Attachments

  • testb4j2.zip
    1.2 KB · Views: 211
  • test_b4a.zip
    1.6 KB · Views: 194

Gnappo jr

Active Member
Licensed User
Longtime User
Thank you Erel, I've already seen what you say, in the future he did it.
But I'm interested in the interoperability of heterogeneous systems. I really enjoy seeing a code running with b4a, Asp, vb.net and it does not work in b4j However, I believe that problems are addressed and not wasted, therefore, at the expense of another month of attempts, I will still try to find a solution to this.
Thanks anyway
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Not sure if this will resolve your issue.
Just adding the bouncycastle jar to the project wont cause it to be considered as a provider, you need a tiny bit of java (or could use javaobject) to add it to the security providers.
B4X:
 #AdditionalJar: bcprov-jdk15on-158.jar
.....
#if java
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.security.Provider;
import java.security.Security;
static{
 Provider BC = new BouncyCastleProvider();
 Security.addProvider(BC);
}
#End If
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
Not sure if this will resolve your issue.
Just adding the bouncycastle jar to the project wont cause it to be considered as a provider, you need a tiny bit of java (or could use javaobject) to add it to the security providers.
B4X:
#AdditionalJar: bcprov-jdk15on-158.jar
.....
#if java
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.security.Provider;
import java.security.Security;
static{
Provider BC = new BouncyCastleProvider();
Security.addProvider(BC);
}
#End If
IT WORKS!!!!!
It worked immediately! Problem solved!

Merci beaucoup, mon ami, félicitations pour votre connaissance de java.
Ma famille est reconnaissante pour aujourd'hui qu'au lieu d'avoir un père et un mari attachés à l'ordinateur, il y aura un père et un mari dédié aux femmes et aux enfants.
Une étreinte vertueus
 
Upvote 0
Top