Class: RC4

### Home Classes Methods

### In Files

- lib/rc4.rb

### Parent

Object

### Methods

- ::new
- #decrypt
- #encrypt
- #encrypt!

### Class/Module Index

Quicksearch

- RC4

No matching classes.

# RC4

### Public Class Methods

new(str) click to toggle source

    # File lib/rc4.rb, line 3
    def initialize(str)
      begin
        raise SyntaxError, "RC4: Key supplied is blank"  if str.eql?('')

        @q1, @q2 = 0, 0
        @key = []
        str.each_byte {|elem| @key << elem} while @key.size < 256
        @key.slice!(256..@key.size-1) if @key.size >= 256
        @s = (0..255).to_a
        j = 0
        0.upto(255) do |i|
          j = (j + @s[i] + @key[i] )%256
          @s[i], @s[j] = @s[j], @s[i]
        end
      end
    end

### Public Instance Methods

decrypt(text) click to toggle source
Alias for: encrypt
encrypt(text) click to toggle source

    # File lib/rc4.rb, line 24
    def encrypt(text)
      process text.dup
    end

Also aliased as: decrypt
encrypt!(text) click to toggle source

    # File lib/rc4.rb, line 20
    def encrypt!(text)
      process text
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.