I have a message in base36 (ie: [a-z0-9]+) and I want to XOR it with a base36 key. Is this possible? What's the easiest way to do that? Can it be done with a one-liner on linux?
我有一条base36(即:[a-z0-9]+)的消息,我想用一个base36键来访问它。这是可能的吗?最简单的方法是什么?linux上的一行代码能完成吗?
1 个解决方案
#1
2
Xoring with perl on the command line
在命令行中使用perl进行Xoring
example xor encode
例子xor编码
perl -e '$a="abc"; $k="flock"; use MIME::Base64; print encode_base64($a ^ $k)'
Bw4MY2s=
example xor decode
例子xor解码
perl -e ' $k="flock"; use MIME::Base64; $a=decode_base64("Bw4MY2s="); print $a ^ $k'
abc
base36 works on numbers and gives strings so you could use a similar scheme on these. The output may not be printable however
base36可以处理数字并提供字符串,因此您可以在这些上面使用类似的方案。但是,输出可能无法打印
perl -e 'use Math::Base36 qw/:all/; $k=encode_base36(35); $m=encode_base36(10); print ($m ^ $k)'
To make this work you'll have to install the CPAN module "Math::Base36". This is available on ubuntu 12.04 as "libmath-base36-perl"
要完成这项工作,你必须安装CPAN模块“Math::Base36”。这在ubuntu 12.04上是可用的“libmath-base36-perl”
#1
2
Xoring with perl on the command line
在命令行中使用perl进行Xoring
example xor encode
例子xor编码
perl -e '$a="abc"; $k="flock"; use MIME::Base64; print encode_base64($a ^ $k)'
Bw4MY2s=
example xor decode
例子xor解码
perl -e ' $k="flock"; use MIME::Base64; $a=decode_base64("Bw4MY2s="); print $a ^ $k'
abc
base36 works on numbers and gives strings so you could use a similar scheme on these. The output may not be printable however
base36可以处理数字并提供字符串,因此您可以在这些上面使用类似的方案。但是,输出可能无法打印
perl -e 'use Math::Base36 qw/:all/; $k=encode_base36(35); $m=encode_base36(10); print ($m ^ $k)'
To make this work you'll have to install the CPAN module "Math::Base36". This is available on ubuntu 12.04 as "libmath-base36-perl"
要完成这项工作,你必须安装CPAN模块“Math::Base36”。这在ubuntu 12.04上是可用的“libmath-base36-perl”