B4J Question Multi Platform Random Number and Ecryprion

kokoroayo

Member
Licensed User
Longtime User
Hi All,

I have a VB6 application that is currently working. It generates token (random number) for a user as when he needs to authenticate a transaction. This token is encrypted and stored in the database for future identification purpose.

Now we need to include a web and mobile side to the application. So I'm asked to develop this. I have chosen to use B4X as against Visual Studio for some reasons. My challenge now is:

1. Creating a script to generate a Random Number/Password sequence that runs on B4X generated apps as well as the existing VB6 application.

2. Creating a reliable encryption script that is understood by B4X generated apps as well as the existing VB6 application.

3. Ensuring these apps can use the same script together without issues.

Any help will be appreciated please.

Thank you.
 

kokoroayo

Member
Licensed User
Longtime User
I actually made a very simple encryption script based on character shift (since it was an internal use app). Im open to change if I can get any other one that works. I can convert existing records if need be.
 
Upvote 0

kokoroayo

Member
Licensed User
Longtime User
Public Function WordCrypt(Word As String) As String 'Function to encript string
Dim PsLen, PsCnt, WordT As String
PsLen = Len(Word)
If PsLen <= 0 Then Exit Function
WordT = ""
For PsCnt = 1 To PsLen
WordT = WordT & Chr(Asc(mId(Word, PsCnt, 1)) + 15)
Next PsCnt
WordCrypt = Trim(WordT)
End Function
 
Upvote 0

kokoroayo

Member
Licensed User
Longtime User
My problem is how to ensure that an encryption made by one device is readable across board.
Tha is:
If The VB6 app encrypts a string, B4X can read and decrypt correctly and vice versa.
The other option could have been to make 1 encryption/decryption module like a dll, or library which makes a universal encryption/decryption. Such can be called and parameters sent to it and it returns the result. This has been a challenge owing to the platform issue VB6 (Com) and B4X (Java).
How do I marry these please?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4A and B4J are based on Java. B4i and B4R are not.

You have two options:
1. Port the code you posted in post #4. Should be simple.
2. Use a common encryption algorithm. I don't know which algorithms are supported by VB6 however the common algorithms are supported by B4X (excluding B4R). Once you correctly implemented an encryption algorithm it will work in all platforms.

Third and best option:
Switch to B4J instead of VB6. You can then use B4XEncryption which is cross platform.
 
Upvote 0
Top