noprotocol / php-mysql-aes-crypt

Encrypt/decrypt data in PHP to a format compatible with MySQL AES_ENCRYPT & AES_DECRYPT functions.
MIT License
23 stars 9 forks source link

Check if string is encrypted #6

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi!

I would find it useful to check if a string is encrypted or not.

Example:

<?php
    use NoProtocol\Encryption\MySQL\AES\Crypter;

    $crypter = new Crypter('mykeystring');
    $encrypted = $crypter->encrypt('foobar');

    if($crypter->verify($encrypted)) {
        echo 'The string is encrypted!';
    } else {
        echo 'Better luck next time!';
    }
?>
annejan commented 6 years ago

The main issue is that I can only think of a tentative way to test this, so it would be a 'possibly correctly encrypted string' test . .