Giter VIP home page Giter VIP logo

openid's Introduction

openid 基于AES的id一对多可逆加密生成器

原理

一句话简述:密钥+明文+盐=密文+盐。

加密:

  1. 给定密钥用作AES密钥(长度128,192,256位)
  2. 给定或随机生成40位长度的盐,将其用作AES加密的初相位和轮数得到轮密钥
  3. 将明文做变长int编码
  4. 将编码后的明文和2中生成的轮密钥做异或操作得到密文
  5. 将密文和盐拼接做base32编码

解密:加密逆操作

优点

  1. 解密纯算法实现,不依赖任何资源,如数据库,nosql
  2. AES算法强度高,速度极快(通常有CPU硬件指令支持)
  3. 采用变长int编码,有效缩短密文长度
  4. 同一明文可对应多个密文

缺点和警告

  1. 高度依赖盐的随机性。因为加密可逆,相同盐必须对应确定的轮密钥,如果已知明文,密文,可以推算出轮密钥,进而使得相同盐的密文全部泄密。

openid's People

Contributors

forsaken628 avatar

Watchers

James Cloos 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.