Sha256: e3624a7370f556475b6102c58f89940ac36f6688a655de5d25df7028d97350f2
Contents?: true
Size: 583 Bytes
Versions: 1
Compression:
Stored size: 583 Bytes
Contents
require "openssl" require "base64" module XapoUtils module_function # Do PKCS#7 padding and encrypting. # # Args: # bytestring (str): The text to encode. # k (int, optional): The padding block size. It defaults to k=16. # # Returns: # str: The padded bytestring. def encrypt(payload, secret) cipher = OpenSSL::Cipher::AES.new("256-ECB") cipher.encrypt cipher.key = secret encrypted = cipher.update(payload) + cipher.final return Base64.encode64(encrypted) end def timestamp; (Time.now.to_f * 1000).to_i end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xapo_sdk-0.2.0 | lib/xapo_utils.rb |