Encrypt Strings & Files Directly in Visual Studio Code Editor
By: Bartosz Wójcik
Tags: Encryption, Visual Studio Code, Hacking, Programming, Security

String encryption is used everywhere in desktop & mobile software. You might not even know about it, but it’s there and I’m going to show you how to do it easier and faster.

String encryption in real-world scenarios

You might ask, where is string encryption used exactly and why?

Plain text password to the database

Let me show you a list of real-world usages:

License system messages are encrypted to prevent finding it easily with a hex-editor, for example, “Your license key is invalid!”. If a cracker / hacker finds it, he can easily find the code that references this string and find the license check code!

Local database connection strings with usernames and passwords to the database are in 99% encrypted in some form. Both for desktop and mobile apps. You cannot avoid it in case of local database installations (like SQLite). You can leave it in plain text, but someone could steal it and use it to dump (steal) your database content in no time.

Localized strings encryption will prevent unauthorized translations of your software (don’t laugh, but it’s a real problem if your software gets cracked it’s often to find it translated with some bogus strings in it like “Cracked by …”.

API endpoints are often encrypted too. You cannot avoid putting it in the source code, but the best you can do to hide it — is to encrypt it.

Why is it even used, why don’t you leave it in plain text? The answer is you can! But why make it easier for dishonest people to reveal your secrets?

competition — stealing your data, using your databases

hackers — trying to exploit your infrastructure using all the intel they can find, including the data found in your software

crackers — trying to crack your software and make it available for free, leaving plain text strings in your software is like giving them road directions

Fast string & file encryption for developers

So how to do it easily? Well, you can always write your own encryptor for the strings or the files and use the same algorithm in your software to decrypt it.

But what if you work with multiple programming languages, like JavaScript, Python, Ruby, or even more at the same time? You would have to write this decryption code in every single programming language to handle the encryption algorithm. All over again.

Introducing StringEncrypt for Visual Studio Code

What does it do? It let you encrypt and hide plain text strings & files contents within your source code in a secure & encrypted form with the help of a polymorphic engine, generating random-looking decryption code every time.

Just one click in Visual Studio Code editor!

StringEncrypt extension in Visual Studio Code

The extension is available here:

StringEncrypt examples

I will show you some of the examples so you can understand how it works.

JavaScript string encryption example

Before:

var superSecretPhrase = "Easy string encryption for developers!";

After:

// encrypted with https://www.stringencrypt.com (v1.4.0) [JavaScript]

// superSecretPhrase = "Easy string encryption for developers!"

var superSecretPhrase = "\uBF59\uC4DE\uE963\uF128\uE48D\u0172\u0917\uF2DC" +

"\uFB41\u0A66\u0BCB\u1CF0\u1C95\u23BA\u2B5F\u3A44" +

"\u5929\u430E\u6953\u5378\u623D\u63A2\u74E7\u74AC" +

"\u8251\u8A37\u943C\u94C1\u9CE6\u830B\uACF0\uB3D5" +

"\uC23A\uCA5F\uCC44\uDA69\uBB0E\uEDD3";



for (var rOnpR = 0, FiuqR = 0; rOnpR < 38; rOnpR++)

{

FiuqR = superSecretPhrase.charCodeAt(rOnpR);

FiuqR -= rOnpR;

FiuqR ^= 0xFFFF;

FiuqR += 0x82A3;

FiuqR = ((FiuqR << 5) | ( (FiuqR & 0xFFFF) >> 11)) & 0xFFFF;

FiuqR += 0xE87C;

FiuqR += rOnpR;

FiuqR -= 0x7CB9;

FiuqR = (((FiuqR & 0xFFFF) >> 7) | (FiuqR << 9)) & 0xFFFF;

FiuqR ^= 0x4928;

FiuqR += rOnpR;

FiuqR --;

FiuqR ^= 0xFC14;

FiuqR -= 0x406C;

FiuqR = (((FiuqR & 0xFFFF) >> 3) | (FiuqR << 13)) & 0xFFFF;

superSecretPhrase = superSecretPhrase.substr(0, rOnpR) + String.fromCharCode(FiuqR & 0xFFFF) + superSecretPhrase.substr(rOnpR + 1);

}

C/C++ string encryption

Before:

wchart_t *wszInvalidLicenseKey = L"Your license key is invalid!";

After:

// encrypted with https://www.stringencrypt.com (v1.4.0) [C/C++] // wszInvalidLicenseKey = "Your license key is invalid!" wchar_t wszInvalidLicenseKey[29] = { 0xB5D9, 0x5DDA, 0x25DC, 0x29DE, 0x91BE, 0x41E2, 0x75E4, 0x6DE6, 0x65D8, 0x59DA, 0x2DDC, 0x65DE, 0x91BE, 0x4DE2, 0x65E4, 0x35E6, 0x91BE, 0x75DA, 0x2DDC, 0x91C0, 0x75E0, 0x59E2, 0x39E4, 0x95E5, 0x41D8, 0x75DA, 0x61DC, 0x95C0, 0x11BE }; for (unsigned int MiBmW = 0, kufpD = 0; MiBmW < 29; MiBmW++) { kufpD = wszInvalidLicenseKey[MiBmW]; kufpD -= MiBmW; kufpD = ~kufpD; kufpD ^= MiBmW; kufpD = ((kufpD << 14) | ( (kufpD & 0xFFFF) >> 2)) & 0xFFFF; kufpD --; kufpD = ~kufpD; kufpD = (((kufpD & 0xFFFF) >> 8) | (kufpD << 8)) & 0xFFFF; kufpD ^= 0x74A5; kufpD -= 0x0422; kufpD = ~kufpD; wszInvalidLicenseKey[MiBmW] = kufpD; }

Python file encryption

This example is about reading, encrypting and inserting encrypted file content within your Python script:

Insert encrypted file contents in your Python source code

Say hello to polymorphic encryption!

Forget about simple xor encryption! StringEncrypt comes with a unique encryption engine.

It’s a polymorphic encryption engine, similar to the encryption methods used by the software protection solutions and advanced computer viruses.

How does it work?

Let me explain how the polymorphic encryption process works.

A random set of encryption commands is selected ( xor , addition , subtraction , bit rotations , bit shifts , logical negation etc.). A random set of helper encryption keys is generated. Every byte of the input string is encrypted with every encryption command in the random set. The decryption code in the selected programming language is generated with a reverse set of encryption commands.

More about polymorphic engines:

How to build a polymorphic engine in C++ — https://www.pelock.com/articles/polymorphic-encryption-algorithms

Polymorphic engine in 32-bit MASM assembler — https://github.com/PELock/Simple-Polymorphic-Engine-SPE32

Poly Polymorphic Engine — https://www.pelock.com/products/poly-polymorphic-engine

Supported programming languages

StringEncrypt engine supports code generation for the following programming languages:

Available editions

StringEncrypt can be used: