Module: OPE::Crypto

Included in:
Cipher
Defined in:
lib/ope-rb/crypto.rb

Instance Method Summary collapse

Instance Method Details

#cipher_encrypt(data) ⇒ Object



25
26
27
28
29
# File 'lib/ope-rb/crypto.rb', line 25

def cipher_encrypt(data)
  
  @cipher.update(data) + @cipher.final
  
end

#create_cipherObject



18
19
20
21
22
23
# File 'lib/ope-rb/crypto.rb', line 18

def create_cipher
  
  @cipher = OpenSSL::Cipher::AES.new(128, :ECB)
  @cipher.encrypt; @cipher.key = @key
  
end

#hash(data) ⇒ Object



12
13
14
15
16
# File 'lib/ope-rb/crypto.rb', line 12

def hash(data)
  
  OpenSSL::Digest::SHA256.digest(data)
  
end

#hash_concat(*args) ⇒ Object



5
6
7
8
9
10
# File 'lib/ope-rb/crypto.rb', line 5

def hash_concat(*args)
  
  lens = args.map { |arg| [1].pack("L") }
  hash((lens + args).join(''))
  
end