ruby – 如何在两个hexa字符串之间进行XOR操作?

栏目: Ruby · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/12331579/how-to-do-the-xor-operation-between-two-hexa-strings

我有两个十六进制字符串.我需要在它们之间进行XOR操作.

我的六角串喜欢,

a = "1A6F2D31567C80644A5BEF2D50B986B";
 b = "EF737F481FC7CDAE7C8B40837C80644";

如何在它们之间进行XOR操作?

你能给出一些指导方针吗?

这适用于任何基础:
>> (a.to_i(16) ^ b.to_i(16)).to_s(16) 
=> "f51c527949bb4dca36d0afae2c39e2f"

但是你可以使用 String#hex 作为十六进制字符串.

翻译自:https://stackoverflow.com/questions/12331579/how-to-do-the-xor-operation-between-two-hexa-strings


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Distributed Systems

Distributed Systems

Sukumar Ghosh / Chapman and Hall/CRC / 2014-7-14 / USD 119.95

Distributed Systems: An Algorithmic Approach, Second Edition provides a balanced and straightforward treatment of the underlying theory and practical applications of distributed computing. As in the p......一起来看看 《Distributed Systems》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具