Crypting under b4ppc and b4a

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!

I have used the following code (crypt.dll) to encrpt and decrypt the items of a csv-file in my basic4ppc app. Is it possible to crypt under b4a with the same algorithmus? Because i want to get both apps (b4ppc and b4a) compatible.

B4X:
Sub Encrypt(String1)
  PasswortByte()=bitPW.StringToBytes(String1,0,StrLength, String1))
  SchluesselByte()=Crypto.Encrypt(Schluessel,PasswortByte()) 
    For i=0 To ArrayLen(SchluesselByte())-1 
        ss=bitPW.DecToHex(SchluesselByte(i))
        If StrLength(ss)<2 Then ss="0" & ss
      s=s & ss
    Next
    PWString=s      
End Sub


Sub Decrypt(String1)
  y=StrLength(String1)/2
  Dim NewArray(y) As Byte
  For z=0 To (StrLength(String1)-1
    NewArray(z)=bitPW.HexToDec(StrAt(String1,z*2) & StrAt(String1,z*2)+1))
  Next
  If ArrayLen(NewArray())=0 Then Return
  PasswortByte()=Crypto.Decrypt(Schluessel,NewArray())
  SchluesselSpeicher=bitPW.BytesToString(PasswortByte(),0,ArrayLen(PasswortByte())) 
End Sub
 

agraham

Expert
Licensed User
Longtime User
I assume you mean CryptoDevice.dll. I don't think the algorithm is easily implemented in Java as it uses the Microsoft CryptDeriveKey API which is not available in Java/Android and would need be specially implemented.

I think you will need to rewrite the encryption to use algorithms supported by my CryptoEx library on Basic4ppc and my Encryption library on Basic4android.
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Hello , agraham!

Do you have a tip for me to get an algorithmus, which I can use under b4ppc and b4a? I think it has something to do with "DES":sign0148:.

I have to make a desktop-version to init and encrypt a small table or csv-file. And on the android-device, i must decrypt the database.

thanks for help....
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…