Skip to content

Instantly share code, notes, and snippets.

@cggit
cggit / index.php
Created February 5, 2023 14:16 — forked from vielhuber/index.php
encryption string, send over url and decrypt it #php
<?php
/* modern method with the help of openssl */
// encryption key (generated with hash('sha256', uniqid(mt_rand(), true)))
define('ENCRYPTION_KEY', '4736d52f85bdb63e46bf7d6d41bbd551af36e1bfb7c68164bf81e2400d291319');
function encrypt($string, $salt = null)
{
if($salt === null) { $salt = hash('sha256', uniqid(mt_rand(), true)); } // this is an unique salt per entry and directly stored within a password
return base64_encode(openssl_encrypt($string, 'AES-256-CBC', ENCRYPTION_KEY, 0, str_pad(substr($salt, 0, 16), 16, '0', STR_PAD_LEFT))).':'.$salt;
}
function decrypt($string)
@cggit
cggit / .gitignore
Created February 3, 2014 02:28 — forked from redoPop/.gitignore
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your