+ README.md\n+ example.php\n + license

This commit is contained in:
2021-02-27 13:52:14 +02:00
parent 3d08bcd3c7
commit d269906413
7 changed files with 58 additions and 18 deletions

18
lib.php
View File

@@ -1,12 +1,4 @@
<?php
// The key to use in the encryption
$key = "my Key";
// The string to encrypt, this can be any string.
$string = "Super secret password we should store away safely";
/**
* @param string $data The data to be encrypted, this can only encrypt strings.
* @param string $key The key to use to encrypt the data, this key should be generated using the openssl_random_pseudo_bytes
@@ -85,12 +77,4 @@ function decryptData( string $data, string $key, string $cipherMethod = 'AES-256
// Return the data
return $data;
}
$encryptedData = encryptData($string, $key);
echo "Encrypted: " . $encryptedData;
echo "\n";
echo "Decrypted: " . decryptData($encryptedData, $key);
echo "\n";
echo "Peak Memory: " . memory_get_peak_usage() / 1024 . "Kb";
}