craftwork/id-obfuscator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

craftwork/id-obfuscator

Composer 安装命令:

composer require craftwork/id-obfuscator

包简介

A base converter to obfuscate database IDs in front end applications

README 文档

README

Build status Code coverage Code quality Packagist Chat

A simple encoder to obfuscate database IDs.

This is particularly useful when you don't want to expose sensitive information about your application, for instance the number of users or orders.

Imagine having URLs like these:

http://example.com/user/5
http://example.com/order/2835

then you can convert them into:

http://example.com/user/J
http://example.com/order/3l

Note

This is not an encryption library and should not be used for security purposes.

It is not advisable saving encoded numbers but encoding and decoding IDs on the fly.

You can use a custom character set and a salt to shuffle the characters. Keep the salt private.

It is not advisable to change these at run time as some users might share or bookmark links. To ensure users don't end up on broken links always use the same character set and salt. If the links are restricted to logged in users it might be a good idea to use a user specific salt, such as a uuid.

Installation

$ composer require craftwork/id-obfuscator

Requirements

PHP 7.0.

Usage

$salt = 'test';
$obfuscator = new IdObfuscator($salt);
$obfuscator->encode(10); // m
$obfuscator->encode(1234566); // oK-k

$obfuscator->decode('m'); // 10
$obfuscator->decode('oK-k'); // 1234566

Character sets

The default character set is bcdefghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ1234567890-_. An additional character set is also built in which only uses lowercase hexadecimal characters (CharacterSet::ofHexCharacters()).

You can provide your own character set if you want to either limit the encoding to certain characters or use different characters. Characters need to be ASCII and the character set must be at least two characters long and not contain any duplicates.

$salt = 'test';
$customCharacterSet = CharacterSet::ofCustomCharacters('ambidextrously');
$obfuscator = new IdObfuscator($salt, $customCharacterSet);
$obfuscator->encode(16); // 10 (string)

统计信息

  • 总下载量: 90
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固