Code Monkey home page Code Monkey logo

rc4's Introduction

rc4

rc4 算法的实现,使用 C、Python、Go 实现

RC4 特点

  • 流密码
  • key 的长度[1,256]
  • 加密数据长度没什么限制

基本步骤

  1. 利用Key生成S盒——The key-scheduling algorithm (KSA)
  2. 利用S盒生成密钥流——The pseudo-random generation algorithm(PRGA)
  3. 密文=密钥流 xor 明文,那么 明文 = 密钥流 xor 密文,明文和密文的长度是一样的
key-scheduling algorithm (KSA)

for i from 0 to 255
    S[i] := i
endfor
j := 0
for i from 0 to 255
    j := (j + S[i] + key[i mod keylength]) mod 256
    swap values of S[i] and S[j]
endfor


Pseudo-random generation algorithm (PRGA)

i := 0
j := 0
while GeneratingOutput:
    i := (i + 1) mod 256
    j := (j + S[i]) mod 256
    swap values of S[i] and S[j]
    K := S[(S[i] + S[j]) mod 256]
    output K
endwhile

encrypt_data = data xor K

rc4's People

Contributors

jerryhanhuan avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

alipeiji bandy101

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.