https://github.com/ismaelsadeeq/otp-stream-cypher
https://github.com/ismaelsadeeq/otp-stream-cypher
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/ismaelsadeeq/otp-stream-cypher
- Owner: ismaelsadeeq
- Created: 2025-02-20T15:32:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-20T15:57:06.000Z (over 1 year ago)
- Last Synced: 2025-02-20T16:40:27.052Z (over 1 year ago)
- Language: C++
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
#### One-Time Pad Stream Cipher
This project implements a simple One-Time Pad (OTP) data encryption and decryption system.
#### How It Works
Stream ciphers encrypt data bit-by-bit or byte-by-byte using a randomly generated keystream.
It does this by XORing the plaintext with the randomly generated key.
### Usage
1. Installation
```sh
git clone https://github.com/ismaelsadeeq/otp-stream-cipher
cd otp-stream-cipher
git clone https://github.com/ismaelsadeeq/crypto-utils
```
2. Include the library in your project
E.g Create a new file, `main.cpp`
```c++
// main.cpp
#include
#include "one_time_pad.h"
int main() {
try {
OneTimePad otp;
// Message to encrypt
std::string message = "Secret123";
// Encrypt the message
auto encrypted = otp.encrypt(message);
std::cout << "Key: " << encrypted.first << "\n"
<< "Cipher: " << encrypted.second << "\n";
// Decrypt the message
std::string decrypted = otp.decrypt(encrypted.first, encrypted.second);
std::cout << "Decrypted message: " << decrypted << std::endl;
} catch (const std::exception& ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
return 1;
}
return 0;
}
```
Note: This implementation doesn't require any external libraries. You can compile it with your preferred C++ compiler.