Bscript: Bipolar Binary Bitwise Script
Bscript: Bipolar Binary Bitwise Script
Bipolar Binary Bitwise Script - The ultra secure human-usable cipher script
I would imagine
If you could understand morse code
a tap dancer would drive you crazy
-Mitch Hedberg
What is Bscript…………………………………………………………………………….2
What is a cipher…………………………………………………………………………... 2
Cipher security…………………………………………………………………………….2
The Bscript cipher…………………………………………………………………………4
Symbols……………………………………………………………………..……. 4
Simplified symbols……………………………………………………………….. 5
Symbol Mapping…………………………………………………………………..6
Duplicate entries…………………………………………………….……. 6
Compound entries………………………………………………………… 8
Operators…………………………………………………………………………..9
Bitwise operators…………………………………………………………..9
Modulo operators…………………………………………………………. 11
Mapped operators………………………………………………………….11
Drawing the operators…………………………………………………….. 12
Cross word operations……………………………………………………………. 12
Input chains………………………………………………………………………..13
Operation chains………………………………………………………………….. 13
Repeated inputs……………………………………………………………………13
Operation Density………………………………………………………………… 14
Number of operations…………………………………………………….. 14
Overlapping conflict……………………………………………………… 14
Reading and writing Bscript……………………………………………………………… 15
Reading Bscript……………………………………………………………………15
Writing Bscript…………………………………………………………………….15
On-line Generator tool……………………………………………………………………. 15
Ultra Secure Bscript……………………………………………………………………….20
Decoding………………………………………………………………………….. 20
Encoding………………………………………………………………………….. 20
Resources and links………………………………………………………………………. 22
What is a Bscript?
Bscript is a script optimized to cipher text, be as secure as possible and hard to crack, while still
being human usable.
What is a cipher?
A cipher is the most basic form of encryption. In it’s simplest form it is a substitution of letters for
alternative symbols with a “key” for deciphering it.
Cipher Security
The security of ciphers, codes and encryption is basically “how hard it is to crack them”. A simple
ciphers can be cracked with a small amount of brute force(brute force is just trying possible cipher
keys until you find the key), others can be so secure not even all the computers on earth could crack
them in a trillion years.
The hardest to crack encryptions require computers to use because the system of encoding and
decoding is so complex that a human would take forever to just encode a single message, and a
single typo would destroy the entire message.
The middle range of ciphers, where a human can still use it without any devices is what we are
looking at here.
Substitution ciphers use a key where characters are swapped with their matching values in a key
eg. a=r, b=g, c=s, d=j, e=p, etc…
Polyalphabetic substitution ciphers are systems where there are many keys. You start with a specific
key. Some symbols represent characters using the key, and other symbols are instructions to switch
to a different a key.
Polyalphabetic ciphers are quite secure, but they require memorizing many keys, so we will not use
them. You could add them on top of Bscript, but I find them hard to apply mentally without having
a chart on hand. Even the “easiest” ones like the Vigenère cipher ( wikipedia article ) use a very
simple rule to generate the keys, but is still unreasonable to use without a chart of keys or device
(not saying impossible, just very burdensome)
Substitution ciphers are most commonly cracked with frequency analysis. Frequency analysis is
where you analyze the frequency characters and patterns. Eg. For a simple 1-to-1 substitution cipher
of common English text, I could look for 1 letter long words, these will mostly be A or I. I can then
assume these symbols are either A or I, next I could look for two and three letter words that start
with those characters, the highest frequency words will probably be AND, AS, IS, IN. etc…
Frequency analysis and methods to resist it are like an arms race, methods to resist frequency
analysis were invented, and better frequency analysis methods were created to crack them.
Polyalphabetic ciphers can “hide” the spaces in words by encoding spaces as symbols too. This
makes them hard to read without actually transcribing first (writing the deciphered message out
character by character, and then reading that version)
Simple 1-to-1 substitution ciphers can’t “hide” their spaces well, even if you do substitute spaces
for symbols, they are pretty quickly identified by frequency analysis no matter how hard you try,
Bscript does not attempt to “hide spaces” because it is designed to be human readable. We want to
be able to decipher it without physically transcribing it, it should be feasible to read using purely
internal mental processes.
A very basic method for increasing frequency analysis resistance is redundancy (having more
characters than needed and switching between different options for each letter randomly)
Redundancy requires a huge index. Bscript will not rely on this, but it can be used.
I have set my total limit of “memorization units” to 100. I think this is a reasonable number.
There will be 64 Bscript characters, and few optional extra things to memorize. (operations)
So, because Bscript does not “hide spaces” or use “high redundancy” it needs a new kind of
“frequency analysis immune system”.
No matter what cipher you use, no matter how secure it is, if you have enough text to analyze then
frequency analysis can crack it. So the measure of frequency analysis resistance is not “can it be
cracked” but instead “how much text do you need to before you can crack it”. Bscript aims to
increase the required volume of text as much as possible while still being written and read mentally.
Finally there is the “Ultra secure Bscript” which first applies a baseline operation to everything to
produce an encoded Bscript string. That encoded Bscript can then use all the other Bscript tools on
top to further encode it.
All encoding methods here are very simple. They operate on single bits, or pairs of bits. Even
though there are 64 symbols, the operations are applied to small pieces of each symbol one at a time
so they are quite easy to do mentally.
The Bscript cipher
Step 1 - Symbols
Bscript uses symbols composed of a string of 2 bit components. Each unit has 4 possible states
ones bit
twos bit ones bit 0 1 00=0= 01=1=
fours bit
00 10 00 01
01 11 01 10
00 10 01 11
0 1 0 2 3 2 0 1 1 1 2 3
Bscript uses a “bipolar bit stream”. Loops are HIGH(1) and corners are LOW(0), their polarity
(left/right side of the stream) like the positive negative sides of an electrical signal, represent
another bit. This would be one of the types of data streams that could be used by trinary computers,
polarity first bit and pulse length second bit.
*Trinary computers had a short lived era of usage but were beat out by binary computers for reasons I won't
get into here.. read up on them if you interested, fun topic.
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
0 0 0 0 0 0 0 0
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
1 1 1 1 1 1 1 1
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
2 2 2 2 2 2 2 2
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
3 3 3 3 3 3 3 3
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
0 0 0 0 0 0 0 0
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
1 1 1 1 1 1 1 1
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
2 2 2 2 2 2 2 2
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
3 3 3 3 3 3 3 3
Each bit of the 2 bit unit is also visually represented as a clear visual property, as opposed to just
using 4 random symbols that don’t break into 2 visual components. This can be important
depending on the “Bscript Operations” you use (keep reading, we get to these in a few pages).
Simplified Symbols
To optimize writing efficiency somehwat we can use simplified symbols. This allows us to remove
some details from the top or bottom of some symbols by allowing corners ( 0s and 1s ) to exists at
the terminal of a line under the right conditions..
3 4
Line terminals can also represent corners.
Rules
1. Count all corners, loops, and line terminals
2. If there are 5 ignore line terminals
3. If there are 4 ignore line terminals that come out of loops
4. If there are 3 use all line terminals
Finally here is a full symbol set with the shortcut characters used when available.
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
0 0 0 0 0 0 0 0
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
1 1 1 1 1 1 1 1
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
2 2 2 2 2 2 2 2
0 0 1 1 2 2 3 3
0 2 0 2 0 2 0 2
3 3 3 3 3 3 3 3
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
0 0 0 0 0 0 0 0
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
1 1 1 1 1 1 1 1
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
2 2 2 2 2 2 2 2
0 0 1 1 2 2 3 3
1 3 1 3 1 3 1 3
3 3 3 3 3 3 3 3
For most alphabets, 32 would be enough, we have 64, but this is important for cipher security.
The most important letters to focus on are A and I because these letter can be 1 letter words. 1 letter
words are very easy targets for cracking.
Multiple copies of I and A would make it harder to crack, but they would probably still be identified
quickly. We could prevent this from affecting other words by only using 1 version for the 1 letter
words and only using other versions for longer word. (this way identifying the 1 letter words
doesn’t help you crack other words)
the more common the letter the more extra version should be added.
Assigning the symbols is also important, if we assign them in any pattern, such as alphabetical
order, this pattern could be discovered, enabling an easy crack of our cipher even on small amounts
of text.
A I Q Y G O W 4
B J R Z H P X 5
C K S A I Q W 6
D L T B J R Z 7
E M U C K S 0 8
F N V D L T 1 9
G O W E M U 2 I
H P X F N V 3 A
Crack resistance : LOW
H L W 2 B M Z I
C 6 Q L F O H Q
V V S A N R I Z
P 3 A O D 8 N 7
G E M B Y 4 E K
A T D X 9 G X 5
P 1 J U S T Y J
Crack resistance : MEDIUM
We can further increase the resistance of any cipher by allowing language modifications
• QU is very obvious because there is ALWAYS a U after a Q. There are several ways to
prevent this from weakening your cipher
eg. Allow substitutions for QU such as Q alone or KW, CW, KU, etc..
• Numbers almost always appear with other numbers and not with letters. This can be solved
by allowing number letter substitutions
eg 0=o, 1=i, 2=z, 3=E, 4=A, 5=S, 6=b, 7=T, 8=X, 9=g
• Some letters like vowels, which are common and follow patterns can have even more copies
added to the index by removing extra copies of less frequent letters, or even completely
removing some less common/substituted letters
eg. remove Q and use KW, remove X and use 8, remove Z and use 2, etc..
There are of course many other ways to modify the language to increase crack resistance, but these
are “layers on top of the cipher” because they can be applied to any cipher. We will not rely on these
in Bscript, just be aware you can always add these to increase security.
The list of common bigrams and trigrams is quite long, and you will have to choose which ones you
think are best. How to choose them is tricky, there are several possible goals
• frequency : use the most common ones
eg. TH, HE, IN,ER, AN,RE are the six most common bigrams
• compression : use the ones that will shorten words the most
eg.THE, AND,ARE are trigrams that are common words and compose many common words
• frequency resistance : use the ones that will hide letter frequency best
eg.QU(U always after U) and TH,SH(H often after T or S)
• language resistance : use the ones that will hide language patterns best
eg.Use 1,2,3 instead of one,two,three, make THE,AND,OR single symbols. This creates
many 1 symbol words to hide the I and A words.
A I Q Y RE ED NG 2
B J R Z ES ND ION 3
C K S TH ON TO ING 4
D L T HE ST OR AL 5
E M U AN NT EA A 6
F N V QU EN TI I 7
G O W THE AT AR 0 8
H P X IN AND TE 1 9
Crack resistance : HIGH *best to not always use compounds, randomize usage
The map is just an example of a higher resistance map, not the best possible map. To
calculate the best possible map for English requires a complex analysis of the
language and a lot of processing power. Best to use a new unknown map not mine.
Step 3 – Operators
This is what makes Bscript unique. Operators allow a characters to be expressed as a function of 2
other characters.
Bitwise Operators
First let’s look at using bitwise operators. Bitwise operations will already be familiar to anyone who
does low level programming. These are special binary operations commonly used in the
fundamental levels of computing logic.
Here are three of the most common bitwise operators AND, OR, and XOR(exclusive OR).
A bitwise operator is applied to 2 binary numbers, the operator is applied to each bit of the numbers
individually.
Above you you see the AND operator. The and operator is is simple “if both are 1 then it output 1,
otherwise, if there are any zeros, if gives 0”
Here you see how we apply the AND operator to a symbol unit in Bscript.
As you can see some operators like AND/OR don’t have “balanced input/output”. AND returns
mostly 0, while OR return mostly 1.
eg. 2 bit AND returns 9x0, 3x1,3x2,1x4
XOR is balanced, the output are evenly balanced between all possible values.
eg. 2 bit XOR returns 4x0,4x1,4x2,4x3
The advantage of bitwise operators is that they are based on simple rules, you do not need to
memorize the 4x4 grid of output values.
Modulo Operators
A Modulo is simply put “remainder if divided by and we do not allow a decimal point”.
So for Bscript we want Modulo 4, this way no matter what math operation we use our answer will
be between 0-3
Modulo operators do not require that you memorize the entire table 16 output values.
Mapped Operators
Finally we can create custom operator maps that do not follow a
specific formula.
Here are 3 operator drawing styles, each can be on top or on bottom, giving 6 possible operators.
You can of course create even more operators. As long as they are visually distinct you can have as
many operators as you want.
Using operators across words can be very valuable because it allows you to conceal short words
which would be otherwise exposed to frequency analysis.
Input chains
Operators can also have longer chains of inputs.
x = ( a Operator b Operator c (
x = (a Operator b Operator c Operator d
a bcx c d xa b
Chaining Inputs makes them more burdensome to read. I prefer not to chain my inputs because with
a little practice reading single operators (2 in 1 out) can become a rather quick reflex, longer chains
requires a lot more time and thought because you have to create a “mental buffer” between
operations and it can easily lead to mistakes(but I suppose this is just a matter of practice and skill).
Operation Chains
The output of one operation can be used as an input for another operation.
Operation chains make it very hard to crack the operations as well as the cipher in general.. If trying
to crack a Bscript cipher that uses a lot of operations then cracking the operation is very important.
To crack the operation frequency analysis will require a very large sample of text, operation chains
will dramatically increases the required quantity of text and make cracking operations even harder.
*cracking the operation means discovering how the operation works. It is possible to crack an
operation without cracking the cipher, or vice-versa. Operation chains make it harder to crack both
the cipher and the operations.
Repeated Input
An input can be used multiple times in a single operation
x = ( y OP y x = ( y OP y OP z x = ( z OP y OP y
yx y xz xy z
Adding a vertical line to the beginning of an operation can indicate that input is repeated., and a
loop ca be added in the later inputs as if it “bounces and falls back onto the same input again”.
Operation Density
So how many operations can we expect to be able to used in a given section of text?
xy x or y 2 symbols
2 chances operation can be used
1/64 1/64
2 operations gives 4 chances, with 4 operations there are 8 chances etc...
yz yz x z x z xy xy
1/64 1/64 1/64 1/64 1/64 1/64
xyz 12 chances
yz yz x z x z xy xy
1/64 1/64 1/64 1/64 1/64 1/64
2 operations gives 24 chances for a match, 4 operations gives 48 chances
*but wait, that means 6 operations gives 72/68, that is more than 100% how is that possible?…
answer : this is a simplified way of looking it at. There would be 72 possible operations to run, each
has an output, many outputs would be the same. The accurate way to calculate the probability is
(63/64) is the probability of one operation NOT giving the desired symbol
“probability of NO match” to the power of “number of chances” = probability of NO match
1 minus probability of NO match = probability of match
1- ( (63/64)^72) = 68%
*BUT!!!! These probability calculations are based on randomness. If you choose your operation
and symbol map carefully you can get do better than random chance by using language patterns to
your advantage.
eg. there is always a U after Q, so if you make “Q OP Q = U” you will beat random chance.
2. Overlapping conflict
Overlapping operations can be difficult. There are situation where it might still be
legible if the operations overlap, but more often they need to be vertically stacked or they become
unclear or too messy to reasonable read.
not legible
not legible
ab ab a bcd e a bcd e
Stacking can be used within reason, but if you stack to many layers to high it eventually becomes
hard to identify which letters below are being pointed to.
Reading & Writing Bscript
Reading Bscript requires some practice but is quite reasonable. Reading symbols just requires
learning the symbol map. Reading operations does take a bit more, but it with practice it can
become a reflex. Writing Bscript symbols is quite easy. Writing operations can be tricky,
specifically finding the best operations to use is the tricky part.
Reading Bscript
There are 2 key elements to reading Bscript
1. Symbols – This is a simple matter of learning the symbol for letter substitutions
2. Operations – This is a bit more complex, and there are 2 approaches
a) memorize the 4x4 operation table
b) learn to apply the operation logic (only applicable to bitwise and math based operators)
Writing Bscript
While writing the individual symbols is straightforward, writing operations is trickier.
Suppose you have some text you want to write. Figuring out just where you can substitute a
symbols with an operations will take some time, especially if you are not yet well practiced in your
symbol map and operations.
To help with writing and accelerate learning there is a Bscript online generator tool that can find
valid operations.
These limitations are there to prevent it from overloading the web server. Searching for
combinations in long strings can take a lot of processing time.
The source code is available if you want to run it yourself and remove the limits
http://www.dscript.org/bscript.zip
If you want to do cross word operations just write the words without spaces.
If you want to search for operations you can consult the operation calculator tool at
http://www.dscript.org/bscript/opcalc.php. Simply copy your key code from the main generator tool
and use it into the key code input on the operation calculator, then enter the value of a symbol (eg
“a”, “s” “ing”, etc..) and if the character is in your map it will list all possible operation that produce
it as the output.
On-line Generator Tool ( http://www.dscript.org/bscript )
Generated Bscript
The input text in Bscript
Word List
A list of the words in the input text
A button for each word that opens
the operation finder for that word
Text Input
Presets
Some exmaple preset character
and operation maps
Symbol Map
Maps the Bscript symbols to
letters or letter combinations
Key code
A key code that can be copied and
saved or pasted and loaded so you
can save and re-use your maps
Operator 1 Map
Map for Operator 1
(above symbols)
Operator 2 Map
Map for Operator 2
(below symbols)
Processed Text
Intermediate code for the generator
Generated Bscript
Vector graphic output of the input text. SVG format, easy to modify adjust and resize. (you may
need to click “save as”. Copying it may not preserve the vector format)
Word List
A list of the words from the input text.
Next to each word is a button “process text” which will bring up a list of possible operations.
Then a list of of possible operations will appear, if you click on an operation it will use it…
You can add more than one operation.
This will show all possible 2 input operations on the first 10 letters of the word.
The generator does not stack operations, so you must do that yourself
Also some operations are are mutually exclusive or create loops
A loop is where 2 or more operations cannot be solved because they rely on inputs from each other.
The third option in the list above is an example of an unsolvable operation loop.
Text Input
Here you can input the text you want to generate
When the generator goes through the text assigning symbols sometimes there are multiple options.
You can set it to either choose the first one in the list, the longest match, or a random match.
Presets
You can load from a few preset maps. The included maps are just starting points for practice.
Symbol Map
Here you can modify the map of symbols. You can enter single characters or string of characters.
Key Code
Once you have designed a character map and operations maps you like, copy this code. You can
paste it in here and press “update key code” to reload it later.
Operator 1 Map
A map for the operator which is drawn above the symbols. There are some preset operator maps that
can be loaded.
Operator 2 Map
A map for the operator which is drawn above the symbols. There are some preset operator maps that
can be loaded.
Processed Text
This is layer of intermediate array values for processing.
You can reference it to see how the text is processed and even modify it directly to manually draw
symbols and operations.
The format is comma delimited (commas between symbols).
Operations are written as “!XY” X and Y are the positions of the input symbols in the word.
Ultra Secure Bscript
Finally we can create an ultra secure Bscript cipher by applying a base operation to everything.
Some operations like XOR or Mod 4 Addition have a special feature, every input can be come any
output. No matter what the first input is there is always a second input for any desired output.
Ultra secure Bscript uses one of these operations on every pair of letters. To decode it just apply the
operation to each pair and take the new string of characters.
Te encode a word first chose any random character, then choose the appropriate character to create
the desired character. If you chose a valid operation, such as XOR, then in “A OP B = C” no matter
what A is there is always a B to produce any C.
You can also add the standard operation method on top of ultra secure Bscript. Just use “process
word” tools after you have loaded it into the “processed text” field at the bottom of the genertor.
Decoding
To decode a string just apply the operation to each pair of letters.
XOR
Same = 0 (1 xor 1 =0 , 0 xor 0 = 0) Not same = 1 (1 xor 1 =0 , 0 xor 0 = 0)
Encoding
To encode a string you can do it manually by starting each word with a random character, and then
adding the appropriate characters to produce the word one pair at a time.
Or go to http://www.dscript.org/bscript/ultra.php
You can import your symbol map and operation map
Then type in your text and press process text, this will produce raw Bscript text
Next press on of the op buttons at the top, this will use that operation to encode the text
After clicking one of the OP buttons, that operation will be used to encode it
On the top you will see what the encoded version would read if not decoded.
Next there is a text box with the encoded text. You can copy this and past it into the “processed
text” box at the bottom of the main Bscript generator. You can then add operations on top.
Free for all to use & modify, even free for commercial use
If you enjoy this script you may enjoy some of my other scripts.
WireScript : http://dscript.org/wirescript.pdf
WireScript allows text to be written with wires in 2D and 3D. WireScript turns text into
physical 3D art.
NailScript : http://dscript.org/nailscript.pdf
NailScript is a way to write text with a hammer and nails. By hammering nails into wood or
other materials very durable and long lasting text can be written.
This work is licensed under a Creative Commons Attribution 4.0 International License.
Based on work by Matthew DeBlock at http://dscript.org
[email protected]