Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micheleriva/caesar-cipher
๐ Dead Simple Caesar Cipher written in Haskell
https://github.com/micheleriva/caesar-cipher
caesar-cipher cipher cipher-algorithms haskell haskell-learning haskell-library
Last synced: 7 days ago
JSON representation
๐ Dead Simple Caesar Cipher written in Haskell
- Host: GitHub
- URL: https://github.com/micheleriva/caesar-cipher
- Owner: micheleriva
- License: mit
- Created: 2019-03-26T10:48:38.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-26T11:29:59.000Z (almost 6 years ago)
- Last Synced: 2024-12-14T12:29:10.391Z (2 months ago)
- Topics: caesar-cipher, cipher, cipher-algorithms, haskell, haskell-learning, haskell-library
- Language: Haskell
- Homepage:
- Size: 234 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE.md
Awesome Lists containing this project
README
Caesar Cipher
s i m p l e ยท h a s k e l l ยท i m p l e m e n t a t i o n
![]()
My goal with this project was to build a Caesar Cipher with the minimum effort.
Why? Because I strongly believe that an awesome language such as Haskell, has the potential to transform the following verbose code in something beautiful:```php
= "A") && ($c <= 'Z')) {
if((ord($c) + $offset) > ord("Z")) {
$encrypted_text .= chr(ord($c) + $offset - 26);
} else {
$encrypted_text .= chr(ord($c) + $offset);
}
} else {
$encrypted_text .= " ";
}
$i++;
}
return $encrypted_text;
}function decrypt($str, $offset) {
$decrypted_text = "";
$offset = $offset % 26;
if($offset < 0) {
$offset += 26;
}
$i = 0;
while($i < strlen($str)) {
$c = strtoupper($str{$i});
if(($c >= "A") && ($c <= 'Z')) {
if((ord($c) - $offset) < ord("A")) {
$decrypted_text .= chr(ord($c) - $offset + 26);
} else {
$decrypted_text .= chr(ord($c) - $offset);
}
} else {
$decrypted_text .= " ";
}
$i++;
}
return $decrypted_text;
}
```why the `hwem` (caesar 2) should I write such an horrible php code when there's Haskell?
# License
[MIT](/LICENSE.md)