protected static function unpad($value)
        {
            $pad = ord($value[($length = Inflector::length($value)) - 1]);
            if ($pad and $pad < static::$block) {
                // If the correct padding is present on the string, we will remove
                // it and return the value. Otherwise, we'll throw an exception
                // as the padding appears to have been changed.
                if (preg_match('/' . chr($pad) . '{' . $pad . '}$/', $value)) {
                    return substr($value, 0, $length - $pad);
                } else {
                    throw new Exception("Decryption error. Padding is invalid.");
                }
            }

            return $value;
        }