Module: TencentTrustsql::Tools::SignGenerator::ClassMethods
- Defined in:
- lib/tencent_trustsql/tools/sign_generator.rb
Instance Method Summary collapse
- #params_to_string(items) ⇒ Object
- #sign(private_key, data) ⇒ Object
- #trans_sign(private_key, data) ⇒ Object
Instance Method Details
#params_to_string(items) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/tencent_trustsql/tools/sign_generator.rb', line 14 def params_to_string items query = items.sort.map do |k, v| v = v.to_json if v.class != String "#{k}=#{v}" if v.to_s != '' end.compact.join('&') puts query query end |
#sign(private_key, data) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/tencent_trustsql/tools/sign_generator.rb', line 23 def sign private_key, data private_key = private_key.to_i digest = Algorithm::Sha256.encode(data) temp_key = 1 + SecureRandom.random_number(TencentTrustsql::CURVE.order - 1) signature = ECDSA.sign(TencentTrustsql::CURVE, private_key, digest, temp_key) end |
#trans_sign(private_key, data) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/tencent_trustsql/tools/sign_generator.rb', line 30 def trans_sign private_key, data private_key = private_key.to_i digest = [].push(data).pack('H*') temp_key = 1 + SecureRandom.random_number(TencentTrustsql::CURVE.order - 1) signature = ECDSA.sign(TencentTrustsql::CURVE, private_key, digest, temp_key) end |