E
E
eldar_web2015-10-13 15:59:49
ruby
eldar_web, 2015-10-13 15:59:49

How to replace this piece of PHP code in Ruby?

There is a code in PHP that hashes the data:
<?php

$arHash = array(
    $m_shop,
    $m_orderid,
    $m_amount,
    $m_curr,
    $m_desc,
    $m_key
);
$sign = strtoupper(hash('sha256', implode(":", $arHash)));
?>

How to turn it into ruby ​​code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-10-13
@eldar_web

https://repl.it/BQA4/1

require 'digest/sha2' 

@arHash = [ 
    'm_shop', 
    'm_orderid', 
    'm_amount', 
    'm_curr', 
    'm_desc', 
    'm_key' 
];

puts Digest::SHA256.hexdigest(@arHash.join(':')).upcase

I Googled the answer to your question in 5 minutes with almost zero knowledge of Ruby.
Try not to be lazy next time and think for yourself. Here is a useful guide for you - www.phptoruby.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question