# Algorithm
Encrypting
1. Perform left circular shift the specified byte array every 8 bits. (num of shift: 0-7)* Perform bit-invertion in case of the shifting position is 0.
2. Encode the bit-rotated byte array into a newly-allocated byte array using the Base64 encoding scheme.
Decrypting
Manipulate in the opposite way.# Examples
Normal 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 invertion | 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://search.maven.org/artifact/com.bsb64/bsb64/1.0.0/jar
JAR direct download
bsb64-1.0.0.jar (3,827 bytes / Compiled with JDK8)
SHA-1: c0ba5ef3839f2ac944902b94b1082e41a9d26813
SHA-256: 4879ddf7e434e622e0c31bd8d72eb0b822dd4acc067fabf0a5648f69d785120f