# Algorithm
Encoding
1. Circularly shift each byte in the byte array to the left by the specified number of bits (0-7).
* If the shift count is 0, invert the bits instead.
2. Encode the bit-rotated byte array using the Base64 encoding scheme.
* If the shift count is 0, invert the bits instead.
2. Encode the bit-rotated byte array using the Base64 encoding scheme.
Decoding
Manipulate in the opposite way.
# Examples
Standard Base64
| Source Text(ASCII) | a | b | c | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Source octets | 97 (0x61) | 98 (0x62) | 99 (0x63) | |||||||||||||||||||||
| Bit pattern | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| Index | 24 | 22 | 9 | 35 | ||||||||||||||||||||
| Base64-encoded | Y | W | J | j | ||||||||||||||||||||
| Encoded octets | 89 (0x59) 01011001 | 87 (0x57) 01010111 | 74 (0x4A) 01001010 | 106 (0x6A) 01101010 |
||||||||||||||||||||
BSB64 (n = 1)
| Source Text(ASCII) | a | b | c | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Source octets | 97 (0x61) | 98 (0x62) | 99 (0x63) | |||||||||||||||||||||
| Bit pattern | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| Bit rotation | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 |
| Index | 48 | 44 | 19 | 6 | ||||||||||||||||||||
| Base64-encoded | w | s | T | G | ||||||||||||||||||||
| Encoded octets | 119 (0x77) 01110111 | 115 (0x73) 01110011 | 84 (0x54) 01010100 | 71 (0x47) 01000111 |
||||||||||||||||||||
BSB64 (n = 0)
| Source Text(ASCII) | a | b | c | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Source octets | 97 (0x61) | 98 (0x62) | 99 (0x63) | |||||||||||||||||||||
| Bit pattern | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| Bit inversion | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| Index | 39 | 41 | 54 | 28 | ||||||||||||||||||||
| Base64-encoded | n | p | 2 | c | ||||||||||||||||||||
| Encoded octets | 110 (0x6E) 01101110 | 112 (0x70) 01110000 | 50 (0x32) 00110010 | 99 (0x63) 01100011 |
||||||||||||||||||||
# Implementation
Java, JavaScript, Python, PowerShell, VBA implementations are available on GitHub.Apache Maven
Maven Central
https://central.sonatype.com/artifact/com.libutil/bsb64
JAR direct download
bsb64-1.0.0.jar (3,686 bytes / Compiled with JDK8)
SHA-1: 06d00e1f65c8d65c0979a9c308c973e7fa68d90f
SHA-256: d5e18cb5a07055f3755691b672cca3f14affc6695cf67a22b8265a70b606682b
# Notice
BSB64 is intended for obfuscation, not for providing confidentiality.This method should not be used where confidentiality must be assured.