node.jsのライブラリをRubyで書き換えようとしています。
しかしどうしてもわからないところがあるので、質問させてください。
node.js
Cam.prototype._passwordDigest = function() { var timestamp = (new Date(Date.now() + (this.timeShift || 0))).toISOString(); var nonce = new Buffer(16); nonce.writeUIntLE(Math.ceil(Math.random() * 0x100000000), 0, 4); nonce.writeUIntLE(Math.ceil(Math.random() * 0x100000000), 4, 4); nonce.writeUIntLE(Math.ceil(Math.random() * 0x100000000), 8, 4); nonce.writeUIntLE(Math.ceil(Math.random() * 0x100000000), 12, 4); var cryptoDigest = crypto.createHash('sha1'); cryptoDigest.update(Buffer.concat([nonce, new Buffer(timestamp, 'ascii'), new Buffer('this.password', 'ascii')])); var passdigest = cryptoDigest.digest('base64'); return { passdigest: passdigest , nonce: new Buffer(nonce).toString('base64') , timestamp: timestamp }; };
をRubyに書き換えようとしているのですが、Rubyでnode.jsのBufferのような上記処理はどのような方法で書けますでしょうか。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/15 02:53
2017/05/15 02:56
2017/05/15 04:25