license cloud done

This commit is contained in:
Yan
2017-11-16 20:46:03 +06:30
parent 178b3484be
commit 29322d952e
5 changed files with 64 additions and 30 deletions

View File

@@ -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