Skip to content

Instantly share code, notes, and snippets.

@maulvi
Created January 3, 2020 05:07
Show Gist options
  • Save maulvi/f5e6d8005a5fc3d06a81396db966b5c1 to your computer and use it in GitHub Desktop.
Save maulvi/f5e6d8005a5fc3d06a81396db966b5c1 to your computer and use it in GitHub Desktop.
<?php
$nonceValue = 'lol';// use nonce that generated while using OAuth.
$readableString = 'xxx';
$encryptedString = 'eyJjaXBoZXJ0ZXh0IjoiTUlTbURQZThWQ1puQm9wT1ZVVjg0T0pLWkJ0UzIwRGp0SkRWWkduRVo5MExDa3JyZitFM2N2UEhMUlNvVW1scGxyS1BBdERWNWt5OHNjNUtQUEpZUUI0bW9YOGh2R0ZBQmZyeWozMFpkUHlORFlKZWo0elI3WkZtV09vN1kwV1dYNUdNYW9RcGZCbEFyRDAwXC9aK01rK0JZc3NqcGhzc0pvSStKSXdPYnlDclc4MDVDdXpONVA5R0N3S0QrTUtDbGJyTERvRWVjOXBvSWgzK3Y0S3o1XC95cG05ZkpIbzBCOUJxYTFVSkVyMmc2NGNIRkJVWmR5SVZRZDVzWTFQXC8zdnBLZTlVVlU4dkpyWm9ybjhRMlJtNWhkM3JRXC9VRWpjNEh5T3AzUG9vZ2wydGZjNGo3ZDh3aUNKQlwvTXlIcEFOczZYR0pxVXNrcXBZdHl0alpUbUNqZW4wODlsb1ltbFlpUTh4SnFkZUxBM0gwOUtVVlJyV3Q0dFplbXYzVUtIY2ZZYXJubWxiaUMwYjJZMmNmTmdWXC9QdVZpZGNuRnkrNGtudkJFTnN6XC83ZnhYWWJUdzhPVVZqWTF0RFlqSGdIY1R2TCtwRUdoalppYW8xT3EwYUkwZHRpSnVWRndSYmgzR1RON0ZCdldTWjh6Slg5eU42d0ZTUVRRd2FSZmJ1b2ZlS0VuYlhZcFpNQlJcL0c4SitRbzVRNlVSRytJZUkyWlRGWHhaZmlTeEYzbGhrTlBMeUtBZ0dXUHNLUGxvNlVKY0E0eWN2KzN1b1NzSWxSTis3eHRQa04xd2JYTkFpV0IxS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NlNTI4Y2VjYzJlNTI3MTAzYTkyY2Y1MWZhZTA5YTE1NTA4ZDlmNTIzMDRiNWNjYzJiMzEwNmQ5OTY4M2Y1ODEyMzVhOWUwMGNiZGMiLCJpdGVyYXRpb25zIjo5OTl9';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div class="resultPlaceholder"></div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="crypto.js"></script><!-- https://github.com/brix/crypto-js/releases crypto-js.js can be download from here -->
<script src="Encryption.js"></script>
<script>
var readableString = '<?php echo $readableString; ?>';
var nonceValue = '<?php echo $nonceValue; ?>';
var encryptedString = '<?php echo $encryptedString; ?>';
// on page loaded.
jQuery(document).ready(function($) {
let encryption = new Encryption();
var encrypted = encryption.encrypt(readableString, nonceValue);
console.log(encrypted);
var decrypted = encryption.decrypt(encrypted, nonceValue);
console.log(decrypted);
var decryptedOldString = encryption.decrypt(encryptedString, nonceValue);
console.log(decryptedOldString);
$('.resultPlaceholder').html('readable string: '+readableString+'<br>');
$('.resultPlaceholder').append('encrypted: '+encrypted+'<br>');
$('.resultPlaceholder').append('decrypted: '+decrypted+'<br>');
$('.resultPlaceholder').append('decrypted from old encrypted string: <strong>'+decryptedOldString+'</strong><br>');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment