# `ichisaki`

A Simple Toolkit just for ***FUN***.

## Requirements

Ensure [NumPy](https://numpy.org/) ([NumPy on GitHub](https://github.com/numpy/numpy/)) is installed already before installing `ichisaki`.

One of most simple ways to install [NumPy](https://numpy.org/) is installing it with `conda`:

```sh
$ conda install numpy
```

## Installation

Currently the latest version of `ichisaki` can be installed with `pip` as following:

```sh
$ pip install ichisaki --upgrade
```

or [from source](https://github.com/sandyzikun/ichisaki/) like other packages.

## Importation

To access `ichisaki` and its functions import it in your Python code like this:

```py
>>> import icsk
```

## Functions

### Crypto

Functions encrypt and decrypt text based on Hill Cipher[^1]:

* Encrypt: `icsk.crypto.encode(x: str) -> str`
* Decrypt: `icsk.crypto.decode(x: str) -> str`
* File Encrypt: `icsk.crypto.fencode(filepath: str, outpath:str=None, forcemode:bool=True) -> "FileIOWrapper"`
* File Decrypt: `icsk.crypto.fdecode(filepath: str, outpath:str=None, forcemode:bool=True) -> "FileIOWrapper"`

For instance:

```py
>>> icsk.crypto.encode("Sharing the World")
'icsk3isk9c3sci9kcs3ki9k3ics9sck3i9ks3ci9c3iks93s9cik3s9ickc3sik9ci3ks93kc9si3cik9sis3kc9s3kci9s3ick9si3ck9i3kcs94star'

>>> icsk.crypto.decode("icsk3isk9c3sci9kcs3ki9k3ics9sck3i9ks3ci9c3iks93s9cik3s9ickc3sik9ci3ks93kc9si3cik9sis3kc9s3kci9s3ick9si3ck9i3kcs94star")
'Sharing the World'

>>> icsk.crypto.encode("Tell Your World")
'icsk3ikc9s3cik9sic3ks9s3ick93ic9sk3ic9kss3cki93ik9scc3iks93i9csk3si9kc3sci9kk3ics93c9sik3i9csk4ever'

>>> icsk.crypto.decode("icsk3ikc9s3cik9sic3ks9s3ick93ic9sk3ic9kss3cki93ik9scc3iks93i9csk3si9kc3sci9kk3ics93c9sik3i9csk4ever")
'Tell Your World'
```

```py
>>> fp = "./speech.txt"

>>> fl = open(fp, "r")

>>> print(fl.read())
Before I talk about the things we human beings like or love, let us make it clear that in different time, places, and conditions, we have different opinions on the same person or the same thing.

Okay, I'm now talking about the thing I like most when I was coding in the lab of my high school, 4 years before.

It's a song called "ODDS&ENDS" written by the artist "ryo" who belongs to an acg producing group called "supercell", telling a story between him and a virtual singer called Hatsune Miku.

Their story lasts from fourteen years ago. He, the artist called "ryo", was once an ordinary and obscure composer. Nobody was willing to sing his song, nobody support him and his artworks. His song could be never used or sung until he met the VOCALOID program and a diva called Hatsune Miku in it. Through his great efforts, their song became popular quickly.

This was the beginning of their story. Nevertheless the artist "ryo" got bored with Miku, even he once lost his original intention of producing songs. Finally he recalled the hard time with Miku and composed the song for her, showing his gratitude.

When I listened this song for the first time, I was programming to learn the algorithm DFS, in short of Depth First Search. It's an algorithm based on the algorithm "recursion" we learnt yesterday. I couldn't process all the details in the program when I deal with the problem related to it. I got tired just like "ryo" used to. I met this song exactly the time I was to give up. With its strength inner, I tried to calm down and rearrange what I learnt. Finally I overcame the problem.

>>> fl.close()

>>> fl = icsk.crypto.fencode(fp)

>>> fl
<_io.TextIOWrapper name='./speech.txt.mikucrypto' mode='w' encoding='UTF-8'>

>>> fl.close()

>>> !cat ./speech.txt.mikucrypto
 ...
```

## Changelog

### Version 0.0.8

* Added API for File Encoding (`.crypto.fencode(...)`) and Decoding (`.crypto.fdecode(...)`);

### Version 0.0.3

* Renamed API `.cipher.hill` to `.crypto`,
  including its functions `.encode()` & `.decode()`;
* Closed configuration of mode changing;

## References

[^1]: CTF Wiki [Hill 密码](https://ctf-wiki.org/crypto/classical/polyalphabetic/#hill)
