Package in java 's equivalent in codenameone - encryption

i have a java api that uses those packages:
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Base64;
i find the equivalence of:
the second(import javabc.SecureRandom;)
and
the third(import com.codename1.util.Base64;)
now i still searching for the equivalente of the first one(MessageDigest)
Thanks

MessageDigest just loads the explicit algorithm dynamically. This sounds good for decoupling of encryption but due to dynamic loading it blocks the optimizer from generating efficient code. If we'd support it we'd need to include all of the possible message digests.
The solution is to create an explicit digest instance such as SHA512Digest etc.

Related

GRPC C++ libraries accountability

When building the GRPC libraries from sources, for example on Android, I counter the following issues:
I have to remove libgrpc_unsecure and libgrpc++_unsecure in order
for the initialization of GRPC not to get stuck.
I see that there are two libraries: libprotobuf and libprotobuf-lite.
Which is the differences between them(other than the fact that
probably the lite version contains less functions), which one I
should include?
When generating the .so libraries it is generating also the .a
libraries and if I use the .a libraries a function is not found, so I
have to get back to using the .so, but in that case should I also use
the .a? If not, is there a way to build just the .so?
Is there a link where it specifies the purpose of each library and what should be used? For example I don't think grpc++_reflection is of some use in my case, but how do I know what it contains without having to pass through every symbol in it? I need to better understand how to use the library files.
Yes, libgrpc and libgrpc_unsecure are mutually exclusive. So you need to choose one as a dependency of your application.
Your interpretation is correct. lite version has less feature so you can try lite first and switch to the regular one if it doesn't fit. You may want to check this https://github.com/protocolbuffers/protobuf/blob/main/src/file_lists.cmake to see what's available and what isn't in the lite.
It depends on how you built gRPC.
gRPC has a couple of libraries but grpc++ is the one you want to link against. I don't think it has a comprehensive doc for what is for what so checking out https://github.com/grpc/grpc/blob/master/CMakeLists.txt is the best thing you can do to understand what features those libraries provide.

Flowtype libdefs -- How to export a class definition from one module and extend it in another?

The project I'm working on uses some 3rd-party libraries in which a main module defines classes that are imported and extended by other, associated modules. In my case the main module is three.js, a JavaScript 3D computer graphics library, and the other modules are extensions that extend the features of the main module. These superclasses are an important part of the interface to the extensions, and I would like to include their contribution. Flow has been a great tool for typechecking the rest of the project, but I haven't been able to describe this particular situation well.
I've played with the existing three.js libdef and looked through several others for ideas, without luck. You can certainly declare/export a class in one module and import its type into another, but while that can be used to describe function parameters and such, you can't define a class that extends the imported type: flow complains that it "Cannot reference type ... [1] from a value position. [type-as-value]". I tried using the Class utility type, but that doesn't seem to be available in a libdef: using it causes a "Cannot resolve name Class. [cannot-resolve-name]" error. Am I missing something obvious here? Perhaps there's an well-known workaround?
Thanks in advance for any suggestions.

How to import external Java libraries in OpenTest framework?

I would like to find out how I can import external libraries into my tests? For example, if i use a Java library for random name/number generation, how do I go about using it in my tests?
Thanks
Before I answer, I would advise that you should avoid using Java code, if you can. For example, a random name/number generator is very easy to implement in JavaScript and you can find plenty of ready-made examples out there. If it's JS code, you can easily embed it in your tests using one of the techniques described here. Even better, you should use capabilities that are provided out-of-the-box with OpenTest: $random and $randomString.
If you really need to use Java code, there are two ways to do it:
The recommended way: create one or more custom OpenTest keywords as described here. This will make it easier for you to maintain your test suite in the future and it also makes it easier for other members of your team to leverage this work in their own tests, especially if they are not familiar with Java.
The "quick and dirty" way: create a user-jars directory in your test actor's working directory and drop the JAR file in there. Then, call your Java code from JavaScript as described here.

javax.swing.tree.RowMapper and org.springframework.jdbc.core.RowMapper

when should we use import for javax.swing.tree.RowMapper and import for
org.springframework.jdbc.core.RowMapper
? Please explain briefly
The different classes serve different purposes, their interface is not the same. JDBC package contains classes to work with databases, swing package contains classes to work with UI. So it depends what you are doing.

Use Poco::Crypto::DigestEngine in Poco::HMACEngine

Poco supports HMACEngine with different hash functions. For example to create a HMAC-SHA1 function I can use HMACEngine<SHA1Engine> hmca_sha1("secret");
This works well with DigestEngine like SHA1Engine and MD5Engine that have a constructor without argument.
Is it possible to use HMACEngine with hash functions from OpenSSL as they are provided by Poco::Crypto::DigestEngine?
The problem is that these functions take a string parameter in their constructor that specifies which hashing algorithm to use. This means HMACEngine<Poco::Crypto:DigestEngine> hmca_xxx("secret"); wouldn't work.
Any idea how to do this?
I think it will require some coding on Poco side. HMAC is accepting any class as template argument, and hoping it is a Digest class ans using methods like digest() that may not even exist. The HMACEngine that instantiates the class as template, so you can´t passa anything to its constructor as it is. In fact I don´t think that is a good use of templates, while I´m not very familiar with using this C++ resource yet, I think one should not expect anything to be available from templated class.
Probably a new HMACEngine for the Crypto module (instead of Foundation module) would be good. But looks like an approach more like the Poco::Crypto::RSADigestEngine would be better than the current template based one. I´ve recently modified Poco::Crypto::RSADigestEngine to be based on Poco::Crypto::DigestEngine instead off old Foundation Poco::DigestEngine, and therefore for next release it will also support all hashes that OpenSSL support. Basically RSADigestEngine creates an instance of a Poco::Crypto::DigestEngine as base and uses it.
I could help on a patch proposal if you create one at github. Poco::Crypto does need some updates :)

Resources