我想通过更改行的顺序来隐藏 csv 文件的列中的秘密消息。
我正在寻找一个确定性且可逆的排列函数。
假设我有按字典顺序排列的行列表 A=[1,2,3,4,5] 。我有5个!= 120 种可能的排列。这意味着我可以保存 6 位消息,因为 2^6 = 64 < 120。
我想要以下函数进行编码和解码。
A = [1,2,3,4,5]
message = '010010'
B = encode(A, message) # [2,1,3,4,5] for example
B = [2,1,3,4,5]
message = decode(B) # get back message
Run Code Online (Sandbox Code Playgroud)
我可以计算所有排列,但如果有很多行,那就需要很长时间。该函数必须处理大量行,例如 10 000 行。因此,如果您有任何建议,我在这里寻求帮助。
在以下示例中,我不了解attr_reader或这样的关键字property:
class Voiture
attr_reader :name
attr_writer :name
property :id, Serial
property :name, String
property :completed_at, DateTime
end
Run Code Online (Sandbox Code Playgroud)
它们如何工作?如何创建自己的?它们是功能,方法吗?
class MyClass
mymagickstuff :hello
end
Run Code Online (Sandbox Code Playgroud) Spirit X3解析器函数使用1 attribut可以很好地工作.当我尝试使用多个属性编译文档中的代码时,它不起作用.
#include <boost/spirit/home/x3.hpp>
#include <iostream>
using namespace std;
using namespace boost::spirit;
string a = "3.2 4.5";
auto begin = a.begin();
auto end = a.end();
double d1 = 0.0, d2 = 0.0;
x3::phrase_parse(begin, end ,
x3::double_ >> x3::double_,
x3::space,
d1, d2); // doesn't work. Accept only 1 attribut
Run Code Online (Sandbox Code Playgroud)
它返回以下错误:
/home/sacha/Dev/vql/vqlcompiler.cpp:20: erreur : no matching function for call to ‘phrase_parse(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >&, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >&, boost::spirit::x3::sequence<boost::spirit::x3::real_parser<double>, boost::spirit::x3::real_parser<double> >, const space_type&, double&, double&)’
x3::double_ >> x3::double_, x3::space, d1, d2); …Run Code Online (Sandbox Code Playgroud) algorithm ×1
boost ×1
boost-spirit ×1
c++ ×1
c++14 ×1
class ×1
permutation ×1
properties ×1
ruby ×1