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) ⇒ Object

Parameters:

  • method (String)

    Cipher methods

  • 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)
  • iv (String)

Returns:

  • (String)

    Decrypted Message



25
26
27
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 25

def decrypt(message)
  translate @decrypt_table, message
end

#encrypt(message) ⇒ String

Encrypt message by provided IV

Parameters:

  • message (String)
  • iv (String)

Returns:

  • (String)

    Encrypted Message



20
21
22
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 20

def encrypt(message)
  translate @encrypt_table, message
end

#iv_lenInteger

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

Returns:

  • (Integer)


32
33
34
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 32

def iv_len
  0
end

#keyString

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

Returns:

  • (String)

    key



39
40
41
# File 'lib/shadowsocks_ruby/cipher/table.rb', line 39

def key
  nil
end