File "ProPackageIDGenerator.php"

Full Path: /home/analogde/www/Massage_v3_debug/MASSAGE_TEST/FTP/application/api/licensing/ProPackageIDGenerator.php
File size: 716 bytes
MIME-type: text/x-php
Charset: utf-8

<?php
    class ProPackageIDGenerator {
        private static $PRO_PACKAGE_ID_LENGTH = 16;
        /**
         * @var string
         */
        private $salt;

        /**
         * ProPackageIDGenerator constructor.
         * @param $salt string
         */
        public function __construct($salt) {
            $this->salt = $salt;
        }

        public function idFromEmail($email) {
            $hash = sha1($this->salt . strtolower($email), true);
            $encodedHash = base64_encode($hash);
            $plainTextEncoded = str_replace(array("=", "+", "/"), "", $encodedHash);
            return substr($plainTextEncoded, 0, $this::$PRO_PACKAGE_ID_LENGTH);
        }
    }