license cloud done
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
require 'openssl'
|
||||
require 'base64'
|
||||
|
||||
class MyAesCrypt
|
||||
@cipher = ""
|
||||
|
||||
@@ -7,11 +10,16 @@ class MyAesCrypt
|
||||
|
||||
def export_key(passphrase)
|
||||
# We want a 256 bit key symetric key based on passphrase
|
||||
# for cloud is lookup
|
||||
# for local is license_key
|
||||
# iv_salt = passphrase+"c2l"
|
||||
digest = Digest::SHA256.new
|
||||
key = digest.update(passphrase)
|
||||
key = digest.digest
|
||||
ENV['AES_KEY'] = cipher_key = key # stores the key in key, and also sets the generated key on the @cipher
|
||||
ENV['AES_IV'] = cipher_iv = @cipher.random_iv # stores the iv in iv, and also sets the generated iv on the @cipher
|
||||
key_digest = digest.update(passphrase)
|
||||
# iv_digest = digest.update(iv_salt)
|
||||
key = key_digest.digest
|
||||
# iv = iv_digest.digest
|
||||
ENV['AES_KEY'] = cipher_key = Base64.encode64(key) # stores the key in key, and also sets the generated key on the @cipher
|
||||
ENV['AES_IV'] = cipher_iv = Base64.encode64(@cipher.random_iv) # stores the iv in iv, and also sets the generated iv on the @cipher
|
||||
return cipher_key, cipher_iv
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user