encryption_helper 1.0.0
encryption_helper: ^1.0.0 copied to clipboard
A simple Dart library providing basic string encryption and decryption using XOR and Caesar cipher techniques. Ideal for lightweight data obfuscation.
Encryption Helper #
A simple Dart library that provides basic string encryption and decryption using XOR and Caesar cipher techniques.
Features #
- XOR cipher encryption and decryption using a single-byte key.
- Caesar cipher encryption and decryption with a customizable shift.
- Handles both uppercase and lowercase letters in Caesar cipher.
- Ignores non-alphabet characters during Caesar operations.
Getting started #
To use this package:
- Add it to your
pubspec.yaml:
dependencies:
basic_encryption_helper: ^0.0.1
Example #
Here's how to use the EncryptionHelper for XOR and Caesar cipher encryption and decryption:
import 'package:encryption_helper/encryption_helper.dart';
void main() {
// XOR cipher example
const key = 42;
final originalText = 'Hello, XOR Cipher!';
final encryptedXOR = EncryptionHelper.xorEncrypt(originalText, key);
final decryptedXOR = EncryptionHelper.xorEncrypt(encryptedXOR, key);
print('Original: $originalText');
print('Encrypted (XOR): $encryptedXOR');
print('Decrypted (XOR): $decryptedXOR');
// Caesar cipher example
const shift = 3;
final caesarPlain = 'Hello, Caesar Cipher!';
final encryptedCaesar = EncryptionHelper.caesarEncrypt(caesarPlain, shift);
final decryptedCaesar = EncryptionHelper.caesarDecrypt(encryptedCaesar, shift);
print('Original: $caesarPlain');
print('Encrypted (Caesar): $encryptedCaesar');
print('Decrypted (Caesar): $decryptedCaesar');
}
Output #
When you run the example, you will see the original text, encrypted text, and decrypted text printed to the console.
Original: Hello, XOR Cipher! Encrypted (XOR): (some encrypted string) Decrypted (XOR): Hello, XOR Cipher! Original: Hello, Caesar Cipher! Encrypted (Caesar): Khoor, Fdhvdu Flskhu! Decrypted (Caesar): Hello, Caesar Cipher!