B4J Library [B4X]B4XCryptFile b4xlib (B4A, B4i, B4J)

B4XCryptFile b4xlib v1.0
Here's another contribution to this great Community of Wizards.
This library handles Strings and Binary files so you can Encrypt/Decrypt them using AES

Credits goes out to ✨Erel and Stevel05✨

Requires:

B4XEncryption
BouncyCastle
StringUtils

Example Usage:

' Encrypt a binary File
B4XCryptFile.EncryptFileUsingAES(SourcePath, SourceFilename, DestinationPath, DestinationFilename, "123456")

' Decrypt a binary File

B4XCryptFile.DecryptFileUsingAES(SourcePath, SourceFilename, DestinationPath, DestinationFilename, "123456")


Enjoy :cool:

/ThRuST
 

Attachments

  • B4XCryptFile.b4xlib
    1.3 KB · Views: 239
Last edited:

ThRuST

Well-Known Member
Licensed User
Longtime User
Interesting reading about encryption algorithms here

Here's another page

(Parts from the page below)

There’s a host of different encryption algorithms available today. Here are five of the more common ones.

  • AES. The Advanced Encryption Standard (AES) is the trusted standard algorithm used by the United States government, as well as other organizations. Although extremely efficient in the 128-bit form, AES also uses 192- and 256-bit keys for very demanding encryption purposes. AES is widely considered invulnerable to all attacks except for brute force. Regardless, many internet security experts believe AES will eventually be regarded as the go-to standard for encrypting data in the private sector.
  • Triple DES. Triple DES is the successor to the original Data Encryption Standard (DES) algorithm, created in response to hackers who figured out how to breach DES. It’s symmetric encryption that was once the most widely used symmetric algorithm in the industry, though it’s being gradually phased out. TripleDES applies the DES algorithm three times to every data block and is commonly used to encrypt UNIX passwords and ATM PINs.
  • RSA. RSA is a public-key encryption asymmetric algorithm and the standard for encrypting information transmitted via the internet. RSA encryption is robust and reliable because it creates a massive bunch of gibberish that frustrates would-be hackers, causing them to expend a lot of time and energy to crack into systems.
  • Blowfish. Blowfish is another algorithm that was designed to replace DES. This symmetric tool breaks messages into 64-bit blocks and encrypts them individually. Blowfish has established a reputation for speed, flexibility, and is unbreakable. It’s in the public domain, so that makes it free, adding even more to its appeal. Blowfish is commonly found on e-commerce platforms, securing payments, and in password management tools.
  • Twofish. Twofish is Blowfish’s successor. It’s license-free, symmetric encryption that deciphers 128-bit data blocks. Additionally, Twofish always encrypts data in 16 rounds, no matter what the key size. Twofish is perfect for both software and hardware environments and is considered one of the fastest of its type. Many of today’s file and folder encryption software solutions use this method.
  • Rivest-Shamir-Adleman (RSA). Rivest-Shamir-Adleman is an asymmetric encryption algorithm that works off the factorization of the product of two large prime numbers. Only a user with knowledge of these two numbers can decode the message successfully. Digital signatures commonly use RSA, but the algorithm slows down when it encrypts large volumes of data.
 

Sifu

Active Member
Can this be used for audio streaming? Or is that too heavy for the cpu. I'd like to know how Spotify or similar do it. (so not downloading in memory and then play, but streaming)
 

ThRuST

Well-Known Member
Licensed User
Longtime User
@Sifu The answer here is dynamic, based on the solution of such a project since there's different approaches how to make such a service work. This library does not use Archiver library which would be useful as a combination to make files smaller before sending them across the web. For audio streaming you might want to look up what codecs Media player supports and adjust to that. I doubt an audio-stream no matter if it's static of streamed can be play an encrypted file unless the codec supports it since it will be related to as a file dump of garbage until it's decrypted back to original form so that will leave you with a challenge. So this library only handles the security aspect of files which might come in useful for many scenarios. Since I needed a way to protect files myself I solved that problem at least. This was my best 2 cents :)

Edit: You should post a new question since it's related to Media player and audio in general.

Good luck!
/ThRuST
 

Sifu

Active Member
@ThRuST sorry for my late reply. Thanks very much for your explanation. I will investigate some more.

Meanwhile I found some interesting read here and here
Seams they use some TCP protocol, quite interesting. I'm not in the search to play thousands of file, just limited to 6 which should change each day for my project.
 
Last edited:
Top