edit export csv
This commit is contained in:
@@ -44,14 +44,16 @@ class BatchLineItem < ApplicationRecord
|
||||
encrypt_key=""
|
||||
|
||||
find_user=User.find_by_id(user_id)
|
||||
|
||||
if !find_user.nil?
|
||||
encrypt_key=find_user.secrect_key
|
||||
encrypt_key=find_user.secrect_key
|
||||
end
|
||||
attributes = %w{serial_no wristband_code batch_id manufacture_uid card_type wristband_token}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << attributes
|
||||
all.each do |encoder|
|
||||
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
|
||||
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
|
||||
|
||||
encryptd_data=BatchLineItem.encrypted(str,encrypt_key)
|
||||
encoder.wristband_token=encryptd_data
|
||||
|
||||
@@ -60,7 +62,7 @@ class BatchLineItem < ApplicationRecord
|
||||
end
|
||||
end
|
||||
def self.encrypted(message,encrypt_key)
|
||||
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
||||
cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
||||
cipher.encrypt
|
||||
|
||||
key = Digest::SHA1.hexdigest(encrypt_key)
|
||||
|
||||
Reference in New Issue
Block a user