Class: ShadowsocksRuby::Cipher::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/shadowsocks_ruby/cipher/table.rb

Overview

Implementation of the Table cipher method.

Note: this cipher method have neither IV or key, so may be incompatible with protocols which needs IV or key.

Normally you should use #build to get an instance of this class.

Instance Method Summary collapse

Constructor Details

#initialize(password) ⇒ Table

Returns a new instance of Table.

Parameters:

  • password (String)

    Password



15
16
17
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 15

def initialize password
  @encrypt_table, @decrypt_table = get_table(password)
end

Instance Method Details

#decrypt(message) ⇒ String

Decrypt message by provided IV

Parameters:

  • message (String)

Returns:

  • (String)

    Decrypted Message



29
30
31
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 29

def decrypt(message)
  translate @decrypt_table, message
end

#encrypt(message) ⇒ String

Encrypt message by provided IV

Parameters:

  • message (String)

Returns:

  • (String)

    Encrypted Message



22
23
24
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 22

def encrypt(message)
  translate @encrypt_table, message
end

#iv_lenInteger

Get the cipher object’s IV length returns 0 for Table

Returns:

  • (Integer)


36
37
38
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 36

def iv_len
  0
end

#keyString

Return the key, which length is decided by the cipher method. returns nil for Table

Returns:

  • (String)

    key



43
44
45
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 43

def key
  nil
end