The logo for the PentaBit Cipher. A pentagram with of 1's and 0's is in the foreground. Behind it is a pyramid of 1's and 0's.
Credit to Mika Marie for the design of the logo

PentaBit Cipher

The PentaBit cipher is my latest creation in my encoding hobbyist journey. I created this cipher one day while trying to come up with a cipher that doesn’t greatly expand the size of the output, like my straddling checkerboard does.

This is also my first cipher which can handle various letter casings, and can handle alphanumeric text. Both of these concepts have given me trouble in the past, so creating a cipher that’s capable of both was a proud moment for me. Also new for me is that this is my first Vigenère cipher, making use of a key word or phrase to complete the encoding.


Plain Text
Secret Key
Plain Text
Plain Text
Secret Key

My Own Analysis

As with all of my ciphers, I do not assume that this is cryptographically secure. As always, though, I do not think it is trivially easy to crack either.


  • Uses a key to further obfuscate the message
  • Uses a bespoke text encoding system to store messages
  • The size of the output is equal to the size of the input


  • Still unable to encode any punctuation, which limits the information that can be relayed with the cipher
  • It’s kind of just an arbitrary text encoding system hidden under a XOR key
    • Just as susceptible to XOR brute-forcing as plaintext once the encoding method is understood

After Thoughts

As I type this out, it dawns on me that maybe this isn’t the greatest cipher in the world. Like I say in the Disadvantages section above, it’s basically just XOR’d ASCII, but instead of ASCII, it’s a custom encoding. That means, though, that it suffers from all the same flaws as plain XOR’d ASCII. Nonetheless, I am still quite proud of this cipher. It’s more capable than any of my past ciphers, and does it in less space. I’m also fond of the fact that I set it up to output as a byte array instead of a string, as this once again allows me to easily use the output as color values in an image. As far as practical uses of this feature goes, I have none. I just think it’s a neat option!


Expand for an explanation
  1. Split the plaintext string into an array of individual characters.
  2. Do the same for the secret key.
  3. For each character in the plaintext.
    1. Use a modified A1Z26 cipher to encode the value and get some meta info about the character.
      • If the character is in the range [A-Za-z].
        1. Get the character’s ordinal position in the alphabet, such that A == 1, B == 2, and Z == 26.
        2. Convert that value into binary. This will only take 5 bits.
        3. Use the 6th bit to store whether that character is uppercase (1) or lowercase (0).
        4. Zero out the 7th and 8th bit.
      • If the character is in the range [0-9].
        1. Convert the character’s decimal value to binary.
          • e.g. "9" == 9 == 0b1001
        2. Zero out the 5th and 6th bit.
        3. Set the 7th bit to 1 to signal that this is a numeric value.
        4. Zero out the 8th bit.
      • For all other values
        1. Set the 8th bit to 1 to signal that we couldn’t encode this value.
          • This will be decoded as a space.
        2. Set the lower 5 bits to be this character’s position in the string modulo 26, and bound to the range [1, 26].
          • So, if a , appears as the 53rd character in a string, it will be represented by 0b10000010.
    2. XOR that encoded byte by the corresponding character in the secret key.
      • The secret key will repeated if the key length is shorter than the length of the plaintext.
    3. Add that byte to the output array
  4. Return the array of encoded bytes.

The full documented encode and decode functions can be found here.

Follow my RSS feed! Follow me on Mastodon! This user uses They/Them pronouns maia crimew Novelty badges from The 88x31 GIF Collection Yesterweb - Reclaim the net Powered by Debian Tor I use Vivaldi! IWC Now! Microformats Webmentions Supported NFT - No Fucking Thanks Sharing is caring. Seed your torrents. Google Chrome is evil! Ralsei Deltarune smoking a fat dart

©2024 |