如果我有密钥和一个数字,如何找到 XOR 哈希的答案
How to find the answer to a XOR hash if I have the key & one number
我有一个组成累积异或哈希的小程序。就好像它是一个储蓄账户,每天都在累积地变大。但从这个意义上说,我们是说答案是累积产生的,而且密钥总是存在的。
我取了一串字符
伪代码:
char H[10] = { "ABCDEFGHI", "[=10=]" };
并且我使用了 9 个 32 位数字密钥以 XOR 加密方式对它们进行散列。
我是这样做的:
for (i;i<10;i++)
bitset<32> K ^= H[i] ^ NUMKEY[i];
现在这使得它在没有我做的微积分绘图的情况下变得不透水(看到我在那里做了什么?)所以K
是微积分点的累积,根据微积分是完全可以预测的。
据我所知,要撤消它,我会
for (i;i<10;i++) {
X=0;
X ^= K ^ NUMKEY[i];
}
是否涉及其他数学?我想我必须接受那个 X
并做一点 K - X
来找到真正的导数。
这是我目前的例程。但是我没有得到我要找的东西。
for_each (std::istreambuf_iterator<char>(in), \
std::istreambuf_iterator<char>(), \
[&] (long x) {
t=s_nop(t,0);
cred.push_back(t);
alpha = static_cast<long>(cred[size]);
delta = static_cast<long>(x);
lambda ^= (alpha ^ delta);
size++;
});
for (;i<bn;i++) {
alpha = static_cast<unsigned long>(cred[bn-1-i]);
int m = lambda.to_ulong(), n = alpha.to_ulong();
long hash1 = abs((m-n-1)%256-1);
delta = static_cast<unsigned long>(hash1);
btrace.push_back(hash1);
cout << hash1 << " ";
}
祝您圣诞快乐。提前致谢!
我认为您可能真正想要的是一次性一卡通。 (该片段是 javascript 作为朝那个方向移动的伪代码)
//ignore these top 3 functions (they're just for printing output)
function appendLine(text, target, space, color) {
var line = document.createElement("div");
line.style.border = "1px solid " + color;
line.style.padding = line.style.margin = space;
line.style["font-family"] = "monospace";
line.appendChild(document.createTextNode(text));
target.appendChild(line);
return line;
}
function makeSection(title) {
var d = appendLine(title, document.body, "5px", "#dddddd");
var results = document.createElement("div");
d.appendChild(results);
return function(result) {
appendLine(result, results, "2px", "#eeeeee");
};
}
function toHex(arr) {
return arr.map(function(n){
var h = (n >>> 0).toString(16).toUpperCase();
while(h.length < 8) h = "0" + h;
return h;
}).join(",");
}
//your message
var H = "ABCDEFGHI".split("").map(function(c){return c.charCodeAt(0)});
//your secret encoding key
var NUMKEY = Array.apply(null, Array(9)).map(function(){return Math.random() * Math.pow(2, 32)});
//what you're doing
(function() {
var section = makeSection("what you're doing:");
section("ABCDEFGHI as array of 32bit numbers: " + toHex(H));
section("NUMKEY: " + toHex(NUMKEY));
var K = 0;
for (var i = 0; i < 10; i++) {
K ^= H[i] ^ NUMKEY[i];
}
section("K: " + toHex([K]));
var X = 0;
for (var i = 0; i < 10; i++) {
X ^= K ^ NUMKEY[i];
}
section("X: " + toHex([X]));
})();
//what you're trying to do
(function() {
var section = makeSection("what you're trying to do:");
section("ABCDEFGHI as array of 32bit numbers: " + toHex(H));
section("NUMKEY: " + toHex(NUMKEY));
var Hs_XORd = 0;
for (var i = 0; i < 10; i++) {
Hs_XORd ^= H[i];
}
section("H's XOR'd together: " + toHex([Hs_XORd]));
var NUMKEYs_XORd = 0;
for (var i = 0; i < H.length; i++) {
NUMKEYs_XORd ^= NUMKEY[i];
}
section("NUMKEY's XOR'd together: " + toHex([NUMKEYs_XORd]));
var K = NUMKEYs_XORd ^ Hs_XORd;
section("K: " + toHex([K]));
var X = K ^ NUMKEYs_XORd;
section("X (should be the same as H's XOR'd together): " + toHex([X]));
})();
//what I think you mean to be doing (one time pad)
(function() {
var section = makeSection("what I think you mean to be doing (one time pad):");
section("ABCDEFGHI as array of 32bit numbers: " + toHex(H));
section("NUMKEY: " + toHex(NUMKEY));
var K = [];
for (var i = 0; i < H.length; i++) {
K[i] = H[i] ^ NUMKEY[i];
}
section("K (encoded message using NUMKEY as one time pad): " + toHex(K));
var X = [];
for (var i = 0; i < K.length; i++) {
X[i] = K[i] ^ NUMKEY[i];
}
section("X (decoded message, should be the same as ABCDEFGHI): " + toHex(X));
})();
我有一个组成累积异或哈希的小程序。就好像它是一个储蓄账户,每天都在累积地变大。但从这个意义上说,我们是说答案是累积产生的,而且密钥总是存在的。
我取了一串字符
伪代码:
char H[10] = { "ABCDEFGHI", "[=10=]" };
并且我使用了 9 个 32 位数字密钥以 XOR 加密方式对它们进行散列。
我是这样做的:
for (i;i<10;i++)
bitset<32> K ^= H[i] ^ NUMKEY[i];
现在这使得它在没有我做的微积分绘图的情况下变得不透水(看到我在那里做了什么?)所以K
是微积分点的累积,根据微积分是完全可以预测的。
据我所知,要撤消它,我会
for (i;i<10;i++) {
X=0;
X ^= K ^ NUMKEY[i];
}
是否涉及其他数学?我想我必须接受那个 X
并做一点 K - X
来找到真正的导数。
这是我目前的例程。但是我没有得到我要找的东西。
for_each (std::istreambuf_iterator<char>(in), \
std::istreambuf_iterator<char>(), \
[&] (long x) {
t=s_nop(t,0);
cred.push_back(t);
alpha = static_cast<long>(cred[size]);
delta = static_cast<long>(x);
lambda ^= (alpha ^ delta);
size++;
});
for (;i<bn;i++) {
alpha = static_cast<unsigned long>(cred[bn-1-i]);
int m = lambda.to_ulong(), n = alpha.to_ulong();
long hash1 = abs((m-n-1)%256-1);
delta = static_cast<unsigned long>(hash1);
btrace.push_back(hash1);
cout << hash1 << " ";
}
祝您圣诞快乐。提前致谢!
我认为您可能真正想要的是一次性一卡通。 (该片段是 javascript 作为朝那个方向移动的伪代码)
//ignore these top 3 functions (they're just for printing output)
function appendLine(text, target, space, color) {
var line = document.createElement("div");
line.style.border = "1px solid " + color;
line.style.padding = line.style.margin = space;
line.style["font-family"] = "monospace";
line.appendChild(document.createTextNode(text));
target.appendChild(line);
return line;
}
function makeSection(title) {
var d = appendLine(title, document.body, "5px", "#dddddd");
var results = document.createElement("div");
d.appendChild(results);
return function(result) {
appendLine(result, results, "2px", "#eeeeee");
};
}
function toHex(arr) {
return arr.map(function(n){
var h = (n >>> 0).toString(16).toUpperCase();
while(h.length < 8) h = "0" + h;
return h;
}).join(",");
}
//your message
var H = "ABCDEFGHI".split("").map(function(c){return c.charCodeAt(0)});
//your secret encoding key
var NUMKEY = Array.apply(null, Array(9)).map(function(){return Math.random() * Math.pow(2, 32)});
//what you're doing
(function() {
var section = makeSection("what you're doing:");
section("ABCDEFGHI as array of 32bit numbers: " + toHex(H));
section("NUMKEY: " + toHex(NUMKEY));
var K = 0;
for (var i = 0; i < 10; i++) {
K ^= H[i] ^ NUMKEY[i];
}
section("K: " + toHex([K]));
var X = 0;
for (var i = 0; i < 10; i++) {
X ^= K ^ NUMKEY[i];
}
section("X: " + toHex([X]));
})();
//what you're trying to do
(function() {
var section = makeSection("what you're trying to do:");
section("ABCDEFGHI as array of 32bit numbers: " + toHex(H));
section("NUMKEY: " + toHex(NUMKEY));
var Hs_XORd = 0;
for (var i = 0; i < 10; i++) {
Hs_XORd ^= H[i];
}
section("H's XOR'd together: " + toHex([Hs_XORd]));
var NUMKEYs_XORd = 0;
for (var i = 0; i < H.length; i++) {
NUMKEYs_XORd ^= NUMKEY[i];
}
section("NUMKEY's XOR'd together: " + toHex([NUMKEYs_XORd]));
var K = NUMKEYs_XORd ^ Hs_XORd;
section("K: " + toHex([K]));
var X = K ^ NUMKEYs_XORd;
section("X (should be the same as H's XOR'd together): " + toHex([X]));
})();
//what I think you mean to be doing (one time pad)
(function() {
var section = makeSection("what I think you mean to be doing (one time pad):");
section("ABCDEFGHI as array of 32bit numbers: " + toHex(H));
section("NUMKEY: " + toHex(NUMKEY));
var K = [];
for (var i = 0; i < H.length; i++) {
K[i] = H[i] ^ NUMKEY[i];
}
section("K (encoded message using NUMKEY as one time pad): " + toHex(K));
var X = [];
for (var i = 0; i < K.length; i++) {
X[i] = K[i] ^ NUMKEY[i];
}
section("X (decoded message, should be the same as ABCDEFGHI): " + toHex(X));
})();