๐ BF-VecCrypt: A Brainfuck-Based Encryption System
๐ง Abstract
This paper presents BF-VecCrypt, a lightweight and obfuscated encryption method built upon the esoteric Brainfuck programming language. The encryption mechanism generates Brainfuck-compatible code to represent plaintext characters, using a shifting key vector (k_vec) and a starting position (s_pos). This approach simulates a virtual pointer and memory manipulation process to encode a message into a Brainfuck-like script.
๐ Key Concepts
๐งฉ Key Vector (k_vec)
A list of ordered symbols used as reference points for generating memory pointer shifts and values. For example:
k_vec = ["a", "b", "c", ..., "z", "[", "]", "<", ">", "+", "-", ".", ",", "0", ..., "9"]
๐ Starting Position (s_pos)
The index in k_vec where the encryption process begins. This defines the initial value at the memory pointer. For example, s_pos = 2 means starting at "c".
๐งฌ Encryption Process
Given:
message = "this is a secret message"k_vec = ["a", "b", "c", ..., "z"]-
s_pos = 1(i.e.,"b")
The encryption algorithm works by:
- Initializing the pointer at the
s_pos. - For each character
chin the message:- Determine its index in
k_vec:target_pos. - Calculate the difference from the current position:
delta = target_pos - current_pos. - Output
>or<abs(delta)times to move the pointer. - Output
+ord(ch)times to increase the cell's value. - Output
.to emit the character. - Update
current_pos = target_pos.
- Determine its index in
๐งฎ Example
Letโs say:
k_vec = ["a", "b", "c", ..., "z"]<br>
s_pos = 1 โ current char = "b"<br>
message = "d"
-
"d"is at index 3 - From
"b"(index 1) โ to"d"(index 3) = delta 2 - BF steps:
-
>>(move pointer 2 steps to the right) -
+++(increase cell value 3 times to simulate 'd' if cell is empty) -
.(output the character)
-
So encrypted form = >>+++.
Repeat this per character in the message. This generates a valid (though mostly non-functional) Brainfuck-like script as a cryptic ciphertext.
๐ Decryption
The recipient:
- Loads the
k_vecands_pos. - Parses the BF-like code.
- Simulates pointer moves and increments to extract each intended character from memory.
- Uses the emitted ASCII values (from
+,-, and.patterns) to reconstruct the plaintext.
๐ก๏ธ Security Notes
- Obfuscation: The ciphertext is essentially a scrambled Brainfuck script, making it unreadable to humans.
-
Key secrecy: Security relies on keeping
k_vecands_possecret. - Not cryptographically strong: This is a fun/educational encryption toy, not secure for real-world applications.
๐ก Use Cases
- Educational purposes (understanding interpreters & encoding).
- Creating esoteric puzzle messages.
- Obfuscation in code golfing or creative art/code pieces.
๐ Conclusion
BF-VecCrypt shows how the minimalistic nature of Brainfuck can inspire creative encryption schemes. While not suitable for secure communication, it provides a fascinating blend of pointer arithmetic and symbolic encoding โ a digital maze that turns ordinary text into a chaotic dance of >+<-.
๐งช Example Usage of BF-VecCrypt
โ๏ธ Original Message
message = "bad"
๐ง Brainfuck Compiler in Python
bf_encrypt.py
k_vec = [chr(i) for i in range(97, 123)] # 'a' to 'z'<br>
s_pos = 1 # Starts at 'b'<br>
<br>
def encrypt_bf(message, k_vec, s_pos):<br>
bf_code = ""<br>
current_pos = s_pos<br>
for ch in message:<br>
target_pos = k_vec.index(ch)<br>
delta = target_pos - current_pos<br>
if delta > 0:<br>
bf_code += ">" * delta<br>
elif delta < 0:<br>
bf_code += "<" * (-delta)<br>
bf_code += "+" * (ord(ch) - ord(k_vec[target_pos]))<br>
bf_code += "."<br>
current_pos = target_pos<br>
return bf_code<br>
<br>
# Example usage<br>
message = "bad"<br>
bf_code = encrypt_bf(message, k_vec, s_pos)<br>
print("๐ Encrypted BF Code:")<br>
print(bf_code)
๐งพ Example Encrypted Output
Encrypted BF Code:<br>
<<<.>>>>>>>>>>>>.<<<.
๐ Brainfuck Reverse Compiler (Decryption)
bf_decrypt.py
def decrypt_bf(bf_code, k_vec, s_pos):<br>
pointer = s_pos<br>
output = ""<br>
for cmd in bf_code:<br>
if cmd == ">":<br>
pointer += 1<br>
elif cmd == "<":<br>
pointer -= 1<br>
elif cmd == ".":<br>
output += k_vec[pointer]<br>
return output<br>
<br>
# Example usage<br>
code = "<<<.>>>>>>>>>>>>.<<<."<br>
k_vec = [chr(i) for i in range(97, 123)]<br>
s_pos = 1<br>
print("๐ Decrypted message:")<br>
print(decrypt_bf(code, k_vec, s_pos))
โ Output of Reverse Compilation
Decrypted message:<br>
bad
๐ก Notes
- This assumes
k_vecis 1-to-1 mapped to lowercase lettersa-z. - It can be extended to include more characters (numbers, symbols, etc).
- The encryption here does not encode ASCII values via
+, but rather symbolically tracks the index position โ a simplified obfuscated form, perfect for BF-themed encryption puzzles.
Let me know if you want:
- The
+and-to encode true ASCII values - Full memory cell simulation
- Or a
.pyor.mdexport version.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.