https://github.com/loneicewolf/compact-caesar-cipher
https://github.com/loneicewolf/compact-caesar-cipher
ciphers classical classical-ciphers crypto cryptography loneicewolf
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/loneicewolf/compact-caesar-cipher
- Owner: loneicewolf
- Created: 2024-03-24T14:56:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-23T14:17:26.000Z (almost 2 years ago)
- Last Synced: 2025-02-17T08:43:32.128Z (about 1 year ago)
- Topics: ciphers, classical, classical-ciphers, crypto, cryptography, loneicewolf
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## $\textcolor{red}{\textsf{Compact Caesar Cipher}}$
=======================================================================================
## GUI Python3 (`Jupyter Notebook`)
```py
import ipywidgets
def r_string(s,k): return(''.join([ chr(97+(ord(c)-97+k)%26) for c in s ]))
def F():
import ipywidgets as widgets
from ipywidgets import HBox, VBox
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display
%matplotlib inline
@widgets.interact
def f(BOX=widgets.Text(value='abcdefghijklmnopqrstuvwxyz', disabled=False),k=range(0,26)):
plain_text = BOX
print(r_string(BOX,k))
F()
```


- [implementation](https://github.com/loneicewolf/ciphers-python/blob/main/Caesar_Cipher.py)
```
def r_string(s,k): return(''.join([ chr(97+(ord(c)-97+k)%26) for c in s ]))
#https://github.com/jupyter-widgets/ipywidgets/issues/1775
import ipywidgets as widgets
out = widgets.Output()
def on_value_change(change):
with out:
#print("here ",change['new'])
k=change['new']
print(r_string("abc",k))
slider = widgets.IntSlider(min=1, max=26, step=1, continuous_update=True)
play = widgets.Play(min=1, interval=50)
slider.observe(on_value_change, 'value')
widgets.jslink((play, 'value'), (slider, 'value'))
widgets.VBox([play, slider, out])
```
=======================================================================================
## JavaScript (js)
- [implementation](http://stackoverflow.com/a/617685/987044)
```js
function rot(s,i) {return s.replace(/[a-zA-Z]/g, function (c) { return String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + i) ? c : c - 26); });}
```

=======================================================================================