AsymmetricCryptography : An extension for asymmetric cryptography

1.Introduction

Hi everyone :slightly_smiling_face:
AsymmetricCryptography is an extension which you can use to add end-to-end encryption(asymmetric encryption) in your app.It uses asymmetric encryption which ensures that your data is safe.

Latest Version: 3.1
Last Updated: 2021-06-30T12:32:00Z

2.Blocks

image

image

3.Documentation

A quick and short documentation for AsymmetricCryptography :

blocks (21)

Generates keys of provided length and raises event 'KeysGenerated' with success and response values.
Note: (i) Big key size will consume more ram.It behaves normal upto 4096.
(ii) Key length should be at least 8 times of string length.
For Example :
A key of length 1024 can encrypt a string of length 128.

component_method

Returns private key in string format

component_method (1)

Returns public key in string format

blocks (22)

Tries to encrypt given string with provided public key and returns encrypted text

blocks (23)

Tries to decrypt given string with provided private key and returns decrypted text

image

Asynchronous version of Decrypt method

image

Asynchronous version of Encrypt method

4.Downloads

Aix can be downloaded from Github Repo:

Hope it helps! :slightly_smiling_face:

13 Likes

What do you do at “the other end” where you send the data?

Some examples ?

4 Likes

Looks promising, will keep an eye on that

1 Like

Is the algorithm public, or is this security by obscurity?

3 Likes

It depends on your needs.If you want to decrypt and read data sent by a user then you can do that using the extension.A perfect example can be chat system where A's message can only be read by B and B's message can only be read by A because public keys are exchanged between them.So A can decrypt B's messages and B can decrypt A's messages.

Thank you @Red_Panda

The algorithm used in RSA but I don't know it is public algorithm or not.

2 Likes

I should have been more explicit, by the “other end” I meant somewhere that wasn’t another app with the same extension. Can decrypting only take place using these blocks ?

No you can decrypt data with Java and some online tools if you have private key.

I get this error in label2 using your example aia, when applying private and public keys in the textboxes. I used 123 and 456 (also tried with words)

java.lang.NullPointerException: Attempt to invoke virtual method 'java.security.PublicKey java.security.KeyFactory.generatePublic(java.security.spec.KeySpec)' on a null object reference

This is probably because cipher and keyfactory have not been initialized because GenerateKeys has not been called.
You can call it a bug of single line.

1 Like

ChangeLog Version 2
Changes

  • Some internal changes so that you don’t have to call ‘GenerateKeys’ method to initialize extension.

Thank you @TIMAI2
You can use external key pair but I can’t say it will work or not if not generated using KeyFactory.

1 Like

Can somebody explain to me how to use this in App Inventor? I don’t know much about asymmetric encryption. I always thought you share the public key and keep the private key secret. Another thing that confuses me is the keyLength. Does that mean I have to generate a key pair each time I want to encrypt something?

This can be a good example:

No you can store keys either in online or offline database.

I mean if my text length is different each time, do I really have to generate a new key? What about different devices, how can I encrypt something on my phone and decrypt on my friend’s phone? Sorry for the questions, I’m evaluating if I can use the extension for one of my projects

1 Like

I think no.You can generate a key of big length like 10240 so it can encrypt/decrypt upto 1280 bytes.But big key length can be a problem in old devices which are running below Android 5.0

First of all generate a key pair of desired length.
Now if you have a hackproof database (Firebase or MySql) then I will recommend to store there.Otherwise store keys in Obfuscated text at build time.

You want me to store my keys in an online database? I don't think that is the purpose of asymmetric encryption...

The two keys reminded me of PGP, can this done with your extension?


Again, sorry for bombarding you with questions

I know it is awkward that's why I said in a hackproof database where keys will be safe.
If not then store keys in Obfuscated text at build time.

Btw, if you want to create chatting app then you will have to exchange keys between receiver and sender.

1 Like

I have no knowledge of PGP but somewhere I read that it uses asymmetric encryption but keys generation is very random.
So I think no.

1 Like

I want this to work , but ....

I tried these blocks, having previously generated a private key and public key with length 1024

When I try to encrypt a string I get:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.security.PublicKey java.security.KeyFactory.generatePublic(java.security.spec.KeySpec)' on a null object reference

which seems to indicate that there is nothing available to generate an encrypted string.

1 Like

OK, this works

but this, with obfuscated text fails on decrypt:

1 Like