Giter VIP home page Giter VIP logo

idadawn / supershortlink Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bryan-cyf/supershortlink

0.0 0.0 0.0 8.48 MB

这是一个基于.NET开源的短链生成及监控系统,包含了短URL的生成、短URL跳转长URL、短URL访问统计以及Web后台监控页面,可以帮助我们更容易地生成短链、监控短链!

License: MIT License

JavaScript 0.49% C# 44.31% HTML 10.23% Batchfile 0.10% Dockerfile 0.25% Less 22.17% SCSS 22.46%

supershortlink's Introduction

Nuget包

Package Name Version Downloads
SuperShortLink.Core NuGet NuGet
SuperShortLink.Api NuGet NuGet

SuperShortLink

这是一个基于.NET开源的短链生成及监控系统,它包含了在线生成短链、短链跳转长链、支持短链访问次数以及Web监控页面,可以帮助我们更容易地生成短链、监控短链!


功能介绍

  • 基于.NET 6开发的后端及Web管理界面
  • 支持自定义短链长度
  • 支持在线短链生成及跳转长链
  • 支持实时统计短链访问次数
  • 支持多种持久化方式:MySQL/PostgreSQL/SqlServer(2012及以上)
  • 傻瓜式配置,开箱即用

文档


  1. 快速开始:项目的运行及接入

  1. 架构设计及原理:项目的整体架构设计,加解密混淆算法原理

Web界面

  • 登录页

  • 首页Dashboard

  • 列表页

  • 应用列表页


更多示例

  1. 查看 使用例子
  2. 查看 测试用例

短URL生成原理:混淆自增算法详解

  • 标准Base64编码表如下:

其中“+”和“/”在 URL 中会被编码为“%2B”以及“%2F”,需要进行再编码,因此直接使用标准 Base64 编码进行短URL 编码并不合适,所以,我们需要针对 URL 场景对 Base64 编码进行改造,Base64 编码表中的 62,63 进行编码移除,更新为Base62编码

混淆加密算法设计

  1. 将标准编码随机打乱 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

举例:打乱成:s9LFkgy5RovixI1aOf8UhdY3r4DMplQZJXPqebE0WSjBn7wVzmN2Gc6THCAKhaut

  1. 6位长度标准编码与打乱后编码的对应关系
    计数器自增Id 标准Base62编码 标准Base62编码(6位字符) 打乱后Base62编码 打乱后Base62编码(6位字符)
    6 G AAAAAG y sssssy
    66 BE AAAABE 9k ssss9k
    100 Bm AAAABm 9E ssss9E

可以看出,虽然打乱了,但还顺序性还是很明显

  1. 将前面补0再倒转,由于6位长度最大11位,为了避免倒转后超过该数值,因此补到10位

    计数器自增Id 打乱后Base62编码(6位字符) 前面补0到10位 倒转数字 倒转后的打乱Base62编码(6位字符)
    6 sssssy 0000000006 6000000000 yPFrgP
    66 ssss9k 0000000066 6600000000 5xWCQH
    100 ssss9E 0000000100 10000000 ssSKph

恢复混淆解密算法设计

将请求收到的短链Key根据打乱后的Base62编码转成十进制数,补0到10位,然后倒转就得到原来的短链Id

短链Key 解析后的十进制数 前面补0到10位 倒转数字
yPFrgP 6000000000 6000000000 6
5xWCQH 6600000000 6600000000 66
ssSKph 10000000 0010000000 100

supershortlink's People

Contributors

bryan-cyf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.