B4A Library Decrypter - De-/Encrypt String to base64 (including compatible php code to de/Encrypt)

Decrypter
Version:
1.05

This Library can be used to
- Encrypt a string to a Hex-View of the encrypted string.. The resulting string only contains the character 0 to 9 and A to F. So it is save to be used in any httputils-call-parameter for example.
- Decrypt a String to its Original String. The string to decode must be the output of the Encrypt-Method.

For the php-side you can use the attached php-class to En- and de-crypt strings which are encrypted by the b4a-library (or by the php itself)

The Library is a wrapper for this Github-Project.

Please note that the Key must be 16 Characters long! Or maybe a multiple of 16. Just want to warn about an Exception i got while developing the wrapper


Decrypter
Version:
1.05

  • Methods:
    • bytesToHex (buf() As Byte) As String
    • decrypt (code As String) As Byte[]
    • encrypt (text As String) As Byte[]
    • encrypt2 (toencrypt() As Byte) As Byte[]
    • hexToBytes (str As String) As Byte[]
  • Crypter
    Methods:
    • Initialize (passphrase As String, Secret As String)
    • decrypt (encrypted As String) As String
      Decode a encrypted base64 string and return the decrypted string
    • encrypt (toEncrypt As String) As String
      Encrypt a string and give back an encrypted and base64 encoded string
    • encrypt2 (toEncrypt() As Byte) As String

This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate (You can donate any amount you want to donate for the library (or my work) :)




Please note that this library is Compatible with B4J too!
 

Attachments

  • DecrypterExample.zip
    11 KB · Views: 1,109
  • libDecrypterV1.0.1.zip
    3.5 KB · Views: 768
  • MCryptPHP.zip
    671 bytes · Views: 902
  • libDecrypterV1.0.5.zip
    3.6 KB · Views: 869
  • DecrypterV1.06.zip
    3.7 KB · Views: 875
Last edited:

Noelkman

Member
Licensed User
Longtime User
Try V1.06 in post #1

http://www.basic4android.de/crypt.php
will output: Hello| = 8fd711a3eb3916a3a5729a56d3628a5b

The output from b4a is
B4X:
    crypt.Initialize("fedcba9876543210","0123456789abcdef")
    Dim teststring As String = "Hello|"
    Dim crypted As String = crypt.encrypt(teststring)
    Log(crypted)



PHP:
<?
include_once './MCrypt.php';
$mcrypt = new MCrypt();
$action = $_GET["action"];
$NewCryptedText = bin2hex ( $mcrypt->encrypt("Hello|",true));
echo "Hello| = " . $NewCryptedText."<br />";
$Text = $mcrypt->decrypt("8fd711a3eb3916a3a5729a56d3628a5b",false);
echo "Decrypted: ".$Text;
?>

Hi DonManfred,

alright it seems to work in V1.06.
Thanks a big bunch! I will give it a bigger test and let you know.
 

Noelkman

Member
Licensed User
Longtime User
Hi DonManfred,
I have created a huge sql result on PHP and it is working like a charm now. Thank you very much for that wrapper.
When donating is there a chance to get a invoice ? I need that.
 

DonManfred

Expert
Licensed User
Longtime User

Nickelgrass

Active Member
Licensed User
Longtime User
Hi,
I have two questions to this lib. Is it possible to de/encrypt with Visual Studio or Python instead of PHP?
Is the string actually safely encrypted?
Thanks
Best regards
 

victormedranop

Well-Known Member
Licensed User
Longtime User
I REALLY LIKE YOUR WORK !!!!!


Decrypter
Version:
1.05

This Library can be used to
- Encrypt a string to a Hex-View of the encrypted string.. The resulting string only contains the character 0 to 9 and A to F. So it is save to be used in any httputils-call-parameter for example.
- Decrypt a String to its Original String. The string to decode must be the output of the Encrypt-Method.

For the php-side you can use the attached php-class to En- and de-crypt strings which are encrypted by the b4a-library (or by the php itself)

The Library is a wrapper for this Github-Project.

Please note that the Key must be 16 Characters long! Or maybe a multiple of 16. Just want to warn about an Exception i got while developing the wrapper


Decrypter
Version:
1.05

  • Methods:
    • bytesToHex (buf() As Byte) As String
    • decrypt (code As String) As Byte[]
    • encrypt (text As String) As Byte[]
    • encrypt2 (toencrypt() As Byte) As Byte[]
    • hexToBytes (str As String) As Byte[]
  • Crypter
    Methods:
    • Initialize (passphrase As String, Secret As String)
    • decrypt (encrypted As String) As String
      Decode a encrypted base64 string and return the decrypted string
    • encrypt (toEncrypt As String) As String
      Encrypt a string and give back an encrypted and base64 encoded string
    • encrypt2 (toEncrypt() As Byte) As String

This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate (You can donate any amount you want to donate for the library (or my work) :)




Please note that this library is Compatible with B4J too!
 
Top