https://github.com/g3th/chuck-norris-cipher
Chuck Norris unary cipher puzzle coded in Kotlin.
https://github.com/g3th/chuck-norris-cipher
chuck-norris chuck-norris-cipher code-puzzle encrypt kotlin
Last synced: 12 months ago
JSON representation
Chuck Norris unary cipher puzzle coded in Kotlin.
- Host: GitHub
- URL: https://github.com/g3th/chuck-norris-cipher
- Owner: g3th
- Created: 2023-05-07T03:51:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-08T16:13:44.000Z (over 3 years ago)
- Last Synced: 2025-03-05T00:27:48.438Z (over 1 year ago)
- Topics: chuck-norris, chuck-norris-cipher, code-puzzle, encrypt, kotlin
- Language: Kotlin
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Chuck Norris Encryption
## The Chuck Norris Unary cipher in Kotlin
### Now With Included Decrypter Function for $0.00!
This is a common code puzzle found on a number of sites (Codewars, Leetcode etc..) and consists of encrypting words or a series of characters using only 0s. The characters are first converted to a binary string 7 bits long (i.e. 1001010), which is the length of ASCII character codes. These binary strings are then joined into a single string and form the input for the encrypting function.
The rules of the cipher dictate that the first occurrence of:
1 (bit on) == 0 + a space
0 (bit off) == 00 + a space
Then, each subsequent recurring 1 or 0 will not include a space until a different digit occurs. These digits will indicate the total number of 1/0s until the sequence breaks. Example:
1100110 would be: 0 00 (two 1s) 00 00 (two 0s) 0 00 (two 1s) 00 0 (one zero)
This script allows the user to choose a mode, and it includes a decrypter function which will decode a Chuck-Norris encoded string to a human-discernible message. There is also error handling which checks for illegal strings in both modes.