PHP code example of ammarfaizi2 / teacrypt

1. Go to this page and download the library: Download ammarfaizi2/teacrypt library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ammarfaizi2 / teacrypt example snippets



eacrypt\Teacrypt;

$string = "hello world";
$key    = "redangel";
$encrypted_string1 = Teacrypt::encrypt($string, $key);
$decrypted_string2 = Teacrypt::decrypt($encrypted_string1, $key);

$encrypted_string2 = Teacrypt::encrypt($string, $key);
$decrypted_string2 = Teacrypt::decrypt($encrypted_string2, $key);

var_dump(array(
        "hasil kesamaan enkripsi 1 dan 2" => ($encrypted_string1 == $encrypted_string2),
        "encrypted_string" => array($encrypted_string1, $encrypted_string2),
        "decrypted_string" => array($decrypted_string2, $decrypted_string2)
    ));



array(3) {
  ["hasil kesamaan enkripsi 1 dan 2"]=>
  bool(false)
  ["encrypted_string"]=>
  array(2) {
    [0]=>
    string(24) "LikCOgUyUFLUmnwMlHXlmLAA"
    [1]=>
    string(24) "rUjyKKDi3WLS3zadlPndULAA"
  }
  ["decrypted_string"]=>
  array(2) {
    [0]=>
    string(11) "hello world"
    [1]=>
    string(11) "hello world"
  }
}