module Encryption
Public Instance Methods
decrypt(data, iv)
click to toggle source
# File lib/game_2d/encryption.rb, line 21 def decrypt(data, iv) decipher = make_cipher.decrypt decipher.key = @symmetric_key decipher.iv = iv decipher.update(data) + decipher.final end
encrypt(data)
click to toggle source
Returns [encrypted, iv]
# File lib/game_2d/encryption.rb, line 14 def encrypt(data) cipher = make_cipher.encrypt cipher.key = @symmetric_key iv = cipher.random_iv [cipher.update(data) + cipher.final, iv] end
key=(key)
click to toggle source
# File lib/game_2d/encryption.rb, line 5 def key=(key) @symmetric_key = key end
make_cipher()
click to toggle source
# File lib/game_2d/encryption.rb, line 9 def make_cipher OpenSSL::Cipher::AES.new(128, :CBC) end
make_password_hash(password)
click to toggle source
Same sort of thing /etc/passwd uses. Provides no security against snooping passwords off the wire, but does make it safer to handle the user password file.
# File lib/game_2d/encryption.rb, line 32 def make_password_hash(password) password.crypt('RB') end