datacapsule 1.0.2 datacapsule: ^1.0.2 copied to clipboard
A simple string (only) masking algorithm that hides a readable string value inside a data capsule using a generated key.
import 'package:datacapsule/datacapsule.dart' as capsule;
class DataCapsule_Examples {
/// Initialize the data capsule class.
capsule.DataCapsule _capsule = capsule.DataCapsule();
/// Sample method to generate a data capsule.
void GenerateCapsule() {
/// * Must get a prescription key before performing any methods of DataCapsule.s
///
/// * A prescription key will be used to encrypt and decrypt. The idea is to create an algorithm
/// * that will hide a readable string inside a data capsule using a prescription key and opening the
/// * data capsule to get the original readable string would require the same key.
///
/// ! If you try to decrypt a string using a different key from what was used to encrypt it,
/// ! the returned string will be different from the original string.
/// Get the prescription key
String _prescription = _capsule.prescription();
/// Pack the string inside a data capsule
String _encryptedString = _capsule.pack(
"I am a string to be placed inside a data capsule.", _prescription);
print(_encryptedString);
/// Unpack the data capsule using the same prescription key that was used for packing.
print(_capsule.unpack(_encryptedString, _prescription));
}
}