Class: CloudEncryptedSync::Cryptographer

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_encrypted_sync/cryptographer.rb

Constant Summary collapse

ALGORITHM =
'AES-256-CBC'

Class Method Summary collapse

Class Method Details

.decrypt_data(ivdata) ⇒ Object



13
14
15
16
17
# File 'lib/cloud_encrypted_sync/cryptographer.rb', line 13

def decrypt_data(ivdata)
  iv= ivdata.byteslice(0..15)
  data = ivdata.byteslice(16..-1)
  crypt_data(:decrypt, iv, data)
end

.encrypt_data(data) ⇒ Object



7
8
9
10
11
# File 'lib/cloud_encrypted_sync/cryptographer.rb', line 7

def encrypt_data(data)
  iv = generate_random_iv
  encrypted_data = crypt_data(:encrypt, iv, data)
  return iv + encrypted_data
end

.hash_data(data) ⇒ Object



19
20
21
# File 'lib/cloud_encrypted_sync/cryptographer.rb', line 19

def hash_data(data)
  Digest::SHA2.hexdigest(data,512)
end