StringEncrypt — String & File Encryption for Python Developers
StringEncrypt allows you to encrypt strings and files using
a randomly generated algorithm, generating a unique decryption code
(so-called polymorphic code) each time in the selected programming language.
cute_wabbit="A little girl goes into a pet show and asks for a wabbit... http..."
Encrypted string in Python source code format
# encrypted with https://www.stringencrypt.com (v1.3.0) [Python]
# cute_wabbit = "A little girl goes into a pet show and asks for a wabbit... http..."
cute_wabbit=[0x1005,0x4004,0x4005,0x5006,0x4003,0x0004,0x4002,0x9001,0x0009,0x300E,0x100F,0xE00F,0xC00A,0x400D,0xF00C,0x300B,0x5013,0x7013,0x8015,0x5012,0xE018,0x0018,0x7016,0xC011,0x1019,0x401E,0x801C,0x901C,0x401D,0x4019,0xB01F,0x401F,0xF02F,0x302F,0x8029,0xD02E,0xE02C,0x002B,0x802E,0xD029,0x3026,0xF026,0xB028,0xC024,0x6022,0xB021,0xA023,0xC027,0x103B,0x4040,0xF03A,0xD03A,0x2040,0x603F,0x103E,0x803E,0xE035,0xA036,0x6037,0xC038,0x8036,0x0036,0xC037,0xC038,0x3058,0xE053,0x7051,0x3052,0x7053,0x3054,0xF051,0x2055,0x005E,0xD05D,0xC060,0x4060,0xF05A,0xA059,0x6060,0x305B,0x2044,0x3044,0x7045,0x8042,0xF048,0x7047,0x7042,0x4045,0x504A,0x904A,0x704B,0xE04B,0xF04A,0x7049,0xB050,0x9050,0x4080,0x1080,0x5079,0xB07D,0x107C,0x607B,0xA07A,0x5079,0x4076]forwEzdtinrange(105):zWqET=cute_wabbit[wEzdt]zWqET-=1zWqET^=wEzdtzWqET=(((zWqET&0xFFFF)>>14)|(zWqET<<2))&0xFFFFzWqET^=wEzdtzWqET=(((zWqET&0xFFFF)>>14)|(zWqET<<2))&0xFFFFcute_wabbit[wEzdt]=zWqETcute_wabbit=''.join(chr(zWqET&0xFFFF)forzWqETincute_wabbit)delwEzdt,zWqETprint(cute_wabbit)
The problem with plain text strings
I'm a developer, and I love programming. I'm also an avid reverse engineer. I perform a wide array of software analysis in my daily work and sometimes I find things in compiled applications that shouldn't be exposed to the
first person with a simple hex-editor in hand.
What can be found in application binaries?
Everything! I've listed a few examples of the things I found below.
Sometimes these things shouldn't even be included in applications
at all (they are there due to poor design choices or rushed work),
but some are just cannot be avoided.
Database passwords
FTP passwords
Login credentials
Encryption & decryption keys
Custom code scripts in readable text
Complex SQL queries in plain text
Hidden website endpoints
BitCoin wallets locations
...and many more
Ask yourself, did you ever put some sensitive content in your software that you later regret?
Why should I care?
If any of these things were to fall into the wrong hands, they could be
used to compromise your software or your infrastructure.
Take for example database passwords. A competitor could use them
to view your database structure or dump all of its contents. You don't want to lose all your hard work because someone with a simple hex-editor can discover your password in plain text.
The solution — String Encrypt
I've decided to create a simple service called String Encrypt for developers, offering fast string & file encryption without the need to write custom encryption tools over and over again because I did that many times.
String Encrypt can help you hide the things that shouldn't be visible at first glance to anyone with a hex-editor.
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 it works?
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.
The encrypted content is different every time you apply StringEncrypt encryption to it.
The algorithm is always unique, the encryption keys are always randomly selected and the decryption code is also unique for every time you use our encryption.
StringEncrypt features
Out of box support for UNICODE (WideChar type in C/C++ languages), UTF-8 (multibyte) & ANSI (single byte) strings encodings
Configurable minimum & maximum number of encryption commands
Different ways to store the encrypted string (as a global or local variable if the selected programming language supports it)
Wide array of supported programming languages
You can automate the encryption process in your builds using our WebAPI interface (PHP and Python bindings)
StringEncrypt allows you to encrypt strings and files using a randomly generated algorithm, generating a unique decryption code (so-called polymorphic code) each time in the selected programming language.
StringEncrypt — String & File Encryption for Python Developers
StringEncrypt allows you to encrypt strings and files using
a randomly generated algorithm, generating a unique decryption code
(so-called polymorphic code) each time in the selected programming
language.
Basic string encryption usage example (with default options)
#!/usr/bin/env python
###############################################################################
#
# String Encrypt WebApi interface usage example.
#
# In this example we will encrypt sample string with default options.
#
# Version : v1.0
# Language : Python
# Author : Bartosz Wójcik
# Project page : https://www.stringencrypt.com
# Web page : https://www.pelock.com
#
###############################################################################
#
# include StringEncrypt module
#
fromstringencryptimportStringEncrypt#
# if you don't want to use Python module, you can import it directly from the file
#
#from stringencrypt.stringencrypt import StringEncrypt
#
# create StringEncrypt class instance (we are using our activation code)
#
myStringEncrypt=StringEncrypt("ABCD-ABCD-ABCD-ABCD")#
# encrypt a string using all the default options
#
result=myStringEncrypt.encrypt_string("Hello, world!","label_encrypted")#
# result[] array holds the encryption results as well as other information
#
# result["error"] (int) - error code
# result["error_string"] (string) - error code as a string
# result["source"] (string) - decryptor source code
# result["expired"] (boolean) - expiration flag
# result["credits_left"] (int) - number of credits left
# result["credits_total"] (int) - initial number of credits
ifresultand"error"inresult:# display source code of the decryption code
ifresult["error"]==StringEncrypt.ErrorCodes.ERROR_SUCCESS:print(result["source"])else:print(f'An error occurred, error code: {result["error"]} ({result["error_string"]})')else:print("Something unexpected happen while trying to encrypt the string.")
number of credits left
*
result["credits_total"] (int)
initial number of credits
Error codes:
*
ERROR_SUCCESS (0)
everything went fine
*
ERROR_EMPTY_LABEL (1)
label parameter is empty
*
ERROR_LENGTH_LABEL (2)
label length is too long
*
ERROR_EMPTY_STRING (3)
input string is empty
*
ERROR_EMPTY_BYTES (4)
input file bytes array is empty
*
ERROR_EMPTY_INPUT (5)
input source (either string or file) is missing
*
ERROR_LENGTH_STRING (6)
string or bytes length is too long
*
ERROR_INVALID_LANG (7)
programming language not supported
*
ERROR_INVALID_LOCALE (8)
language locale is not supported
*
ERROR_CMD_MIN (9)
invalid number of minimum encryption commands
*
ERROR_CMD_MAX (10)
invalid number of maximum encryption commands
*
ERROR_DEMO (100)
you need a valid code to use full version features
Custom string encryption for other programming languages
#!/usr/bin/env python
###############################################################################
#
# String Encrypt WebApi interface usage example.
#
# In this example we will encrypt sample strings with custom options.
#
# Version : v1.0
# Language : Python
# Author : Bartosz Wójcik
# Project page : https://www.stringencrypt.com
# Web page : https://www.pelock.com
#
###############################################################################
#
# include StringEncrypt module
#
fromstringencryptimportStringEncrypt#
# if you don't want to use Python module, you can import it directly from the file
#
#from stringencrypt.stringencrypt import StringEncrypt
defprint_results(result):#
# result[] array holds the encryption results as well as other information
#
# result["error"] (int) - error code
# result["error_string"] (string) - error code as a string
# result["source"] (string) - decryptor source code
# result["expired"] (boolean) - expiration flag
# result["credits_left"] (int) - number of credits left
# result["credits_total"] (int) - initial number of credits
ifresultand"error"inresult:# display source code of the decryption code
ifresult["error"]==StringEncrypt.ErrorCodes.ERROR_SUCCESS:print(result["source"])else:print(f'An error occurred, error code: {result["error"]} ({result["error_string"]})')else:print("Something unexpected happen while trying to encrypt the string.")#
# create StringEncrypt class instance (we are using our activation code)
#
myStringEncrypt=StringEncrypt("ABCD-ABCD-ABCD-ABCD")#
# encrypt a string using all the default options
#
result=myStringEncrypt.encrypt_string("Hello","label")print_results(result)#
# lets change the output programming language into C++
#
myStringEncrypt.outputProgrammingLanguage=StringEncrypt.OutputProgrammingLanguages.LANG_CPPresult=myStringEncrypt.encrypt_string("C++","wszLbl")print_results(result)#
# change the encoding of the string to ANSI
#
myStringEncrypt.useUnicode=Falseresult=myStringEncrypt.encrypt_string("ANSI!","szLbl")print_results(result)#
# change to JavaScript language output and see the difference
# between local variable encoding and global variable encoding
#
myStringEncrypt.useUnicode=TruemyStringEncrypt.outputProgrammingLanguage=StringEncrypt.OutputProgrammingLanguages.LANG_JSmyStringEncrypt.declareAsLocalVariable=Trueresult=myStringEncrypt.encrypt_string("Local","local")print_results(result)#
# switch to global variable encoding (if possible for the programming language)
#
myStringEncrypt.declareAsLocalVariable=Falseresult=myStringEncrypt.encrypt_string("Global","global")print_results(result)
number of credits left
*
result["credits_total"] (int)
initial number of credits
Error codes:
*
ERROR_SUCCESS (0)
everything went fine
*
ERROR_EMPTY_LABEL (1)
label parameter is empty
*
ERROR_LENGTH_LABEL (2)
label length is too long
*
ERROR_EMPTY_STRING (3)
input string is empty
*
ERROR_EMPTY_BYTES (4)
input file bytes array is empty
*
ERROR_EMPTY_INPUT (5)
input source (either string or file) is missing
*
ERROR_LENGTH_STRING (6)
string or bytes length is too long
*
ERROR_INVALID_LANG (7)
programming language not supported
*
ERROR_INVALID_LOCALE (8)
language locale is not supported
*
ERROR_CMD_MIN (9)
invalid number of minimum encryption commands
*
ERROR_CMD_MAX (10)
invalid number of maximum encryption commands
*
ERROR_DEMO (100)
you need a valid code to use full version features
Check the status of the activation code and show current limitations
This example shows how to get information about the current activation code and its features.
#!/usr/bin/env python
###############################################################################
#
# StringEncrypt WebApi interface usage example.
#
# In this example we will verify our activation code status.
#
# Version : v1.0
# Language : Python
# Author : Bartosz Wójcik
# Project page : https://www.stringencrypt.com
# Web page : https://www.pelock.com
#
###############################################################################
#
# include StringEncrypt module
#
fromstringencryptimportStringEncrypt#
# if you don't want to use Python module, you can import it directly from the file
#
#from stringencrypt.stringencrypt import StringEncrypt
#
# create StringEncrypt class instance (we are using our activation code)
#
myStringEncrypt=StringEncrypt("ABCD-ABCD-ABCD-ABCD")#
# login to the service
#
result=myStringEncrypt.is_demo()#
# result[] array holds the information about the license
#
# result["demo"] (boolean) - demo mode flag
# result["label_limit"] (int) - label limit length
# result["string_limit"] (int) - string limit length
# result["bytes_limit"] (int) - bytes/file limit length
# result["credits_left"] (int) - number of credits left
# result["credits_total"] (int) - initial number of credits
# result["cmd_min"] (int) - minimum number of encryption commands
# result["cmd_max"] (int) - maximum number of encryption commands
#
ifresult:print(f'Demo version status - {"True"ifresult["demo"]else"False"}')print(f'Label length limit - {result["label_limit"]}')print(f'String length limit - {result["string_limit"]}')print(f'File bytes limit - {result["bytes_limit"]}')print(f'Usage credits left - {result["credits_left"]}')print(f'Total usage credits - {result["credits_total"]}')print(f'Min. number of encryption commands - {result["cmd_min"]}')print(f'Max. number of encryption commands - {result["cmd_max"]}')else:print("Something unexpected happen while trying to login to the service.")
Each activation code has an assigned number of usage credits. You can use the software in full version as many times as you have usage credits on your account balance.
How to get a free activation code?
You can get a free activation code (500 usage credits) if you can advertise StringEncrypt service with a link to the project site https://www.stringencrypt.com/ at:
Programming forums
Programming blogs
Technical articles
Twitter / Facebook / other social media site
...or any other website related to programming and development
Send me all the details at my contact address and if it's legit - bam!, you got yourself a free code :)
Changelog
[1.0.0] - 2021-01-03
Initial release of a StringEncrypt Python 3 module
Fin
I hope you like it and you will try it at least :)