Encryption 解码十六进制异或加密

Encryption 解码十六进制异或加密,encryption,decoding,xor,hex,Encryption,Decoding,Xor,Hex,所以我读它是为了解密 9887702584b28e6c71b7bb997e7195bf817a3884bf98353889fa9f7d34c7bc8a7625c7ae837425cbfa9e7b258eb6cb73308ea8876c7195bf88703f93b69239718eaecb623094fa9b673e85bb897928c798997c2586b3853222c7b88e6625c7b18e6525c7a98e762382aec535058fb398353894fa897032

所以我读它是为了解密

 9887702584b28e6c71b7bb997e7195bf817a3884bf98353889fa9f7d34c7bc8a7625c7ae837425cbfa9e7b258eb6cb73308ea8876c7195bf88703f93b69239718eaecb623094fa9b673e85bb897928c798997c2586b3853222c7b88e6625c7b18e6525c7a98e762382aec535058fb398353894fa89703286af98707188bccb613982fa98703295bf886c7194af99673e92b48f7c3f80fa8a793dc7ae83707186b99f7c278eae827022c7b98a67238ebf8f353e89fa83702382fa8f60238eb48c350688a8877171b0bb99350590b5cb623094fa84737191b39f743dc7b386653e95ae8a7b3282fa9f7a7188af99353f86ae827a3f86b6cb663484af997c259efa8a7b35c7af8761388abb9f707191b388613e95a3c5

我需要将其拆分为5个通道,并求解单字节异或键,得到一个候选键daeb1551e7。我的问题是,您如何知道需要将其拆分为多少个不同的频道,以及拆分发生的位置

这是我得到的,它是用javascript编写的:

var cryptmsg="9887702584b28e6c71b7bb997e7195bf817a3884bf98353889fa9f7d34c7bc8a7625c7ae837425cbfa9e7b258eb6cb73308ea8876c7195bf88703f93b69239718eaecb623094fa9b673e85bb897928c798997c2586b3853222c7b88e6625c7b18e6525c7a98e762382aec535058fb398353894fa89703286af98707188bccb613982fa98703295bf886c7194af99673e92b48f7c3f80fa8a793dc7ae83707186b99f7c278eae827022c7b98a67238ebf8f353e89fa83702382fa8f60238eb48c350688a8877171b0bb99350590b5cb623094fa84737191b39f743dc7b386653e95ae8a7b3282fa9f7a7188af99353f86ae827a3f86b6cb663484af997c259efa8a7b35c7af8761388abb9f707191b388613e95a3c5";
var key="daeb1551e7";
var hexmsg=Array.from(cryptmsg);
var hexkey=Array.from(key);
var channels=[

];

while(hexkey.length){
  var buffer=hexkey.splice(0,2);
  var channel={
    msg:[],
    key:buffer.join("")
  };
  channels.push(channel);
}

var chanIndex=0;
while(hexmsg.length){
  var buffer=hexmsg.splice(0,2);
  channels[chanIndex].msg.push(buffer);
  chanIndex++;
  chanIndex=chanIndex%5;
}
var channelResults=channels.map(function(channel){
  var nkey=parseInt(channel.key,16);
  return channel.msg.map(
    function(pair){return pair[0]+pair[1];}
  ).map(function(hexchar){
    var nchar=parseInt(hexchar,16);
    var ndec=nchar^nkey;
    return String.fromCharCode(ndec);
  });
});
var decodedMsg=[];
chanIndex=0
while(1){
  var chresult=channelResults[chanIndex];
  if(chresult.length<=0)break;
  decodedMsg.push(chresult.shift());
  chanIndex++;
  chanIndex=chanIndex%5;
}
decodedMsg.join("");
事实证明,每个通道都有自己的一个字节密钥,特定通道的“消息”是从原始加密消息(即字节1到通道1,字节2到通道2,…,字节6到通道1)循环获取的字节十六进制对聚合而成的。使用单字节键进行解码。然后,通过反转我们将加密的消息字节“整理”到它们的通道中所采取的过程来重构最终解密的消息

使现代化 紧凑型:

var cryptmsg="9887702584b28e6c71b7bb997e7195bf817a3884bf98353889fa9f7d34c7bc8a7625c7ae837425cbfa9e7b258eb6cb73308ea8876c7195bf88703f93b69239718eaecb623094fa9b673e85bb897928c798997c2586b3853222c7b88e6625c7b18e6525c7a98e762382aec535058fb398353894fa89703286af98707188bccb613982fa98703295bf886c7194af99673e92b48f7c3f80fa8a793dc7ae83707186b99f7c278eae827022c7b98a67238ebf8f353e89fa83702382fa8f60238eb48c350688a8877171b0bb99350590b5cb623094fa84737191b39f743dc7b386653e95ae8a7b3282fa9f7a7188af99353f86ae827a3f86b6cb663484af997c259efa8a7b35c7af8761388abb9f707191b388613e95a3c5";
var key="daeb1551e7";
var aCryptMsg=Array.prototype.slice.call(cryptmsg);
var aKey=Array.prototype.slice.call(key);
var chanKey=[];
var chanIndex=0;
var aDecryptMsg=[];
function dec(nkey,ncrypt){
    var ndec=nkey^ncrypt;
    return String.fromCharCode(ndec); 
}
while(aKey.length){
  var buffer=aKey.splice(0,2);
  var nkey=parseInt(buffer.join(""),16);
  chanKey.push(nkey);
}
while(aCryptMsg.length){
  var buffer=aCryptMsg.splice(0,2);
  var ncrypt=parseInt(buffer.join(""),16);
  var debuf=dec(chanKey[chanIndex],ncrypt);
  aDecryptMsg.push(debuf);
  chanIndex=(++chanIndex)%5;
}
aDecryptMsg.join("");

/*
Bletchey Park rejoices in the fact that, until fairly recently, it was probably Britain's best kept secret. This is because of the secrecy surrounding all the activities carried on here during World War Two was of vital importance to our national security and ultimate victory.
*/
要查看的解决方案:


以下是如何确定有多少个通道:

将加密的字节序列向右移动一个位置。用左边的0x00填充。然后将结果与原始字符串进行异或运算,并计算零位数。如果零位约为位的65%,则键有一个字节。如果零位大约是位的50%,那么密钥没有一个字节,我们再试一次

获取原始的加密字节序列,并将其向右移动两处。在左侧用0x0000填充。将结果与原始结果进行异或运算。如果得到65%的零位,则密钥有两个字节。如果为50%,则不是两个字节

继续,直到在键中找到byres的数量

对于您的信息,以下是百分比:

1字节移位:48.4% 2字节移位:47.1% 3字节移位:47.5% 4字节移位:48.6%
5字节移位:66.7%您使用的加密算法是什么?很多密码都使用XOR,所以称这种XOR加密并不能真正提供任何信息。我指的是网站上的一个部分:向下滚动,直到到达标题XOR Extended:Multi-byte Repeated XOR,再往下一点就是我在问题中输入的数字。我想知道键值是如何找到的基于这一点,看起来5是多字节键的猜测长度,基于汉明距离,将其拆分为通道意味着提取所有与键字节0、5、10…的第一个字节异或的字节,所有与键1、6、11…的第二个字节异或的字节…,等等但这类事情与编程无关,与StackOverflow无关;那就更合适了。是什么让它必须被分成5个通道呢?@Lanhasts你实际上不需要把数据分成5个通道,我这么做只是因为我匆忙地把一些东西放在一起。表示键的十个十六进制数字需要拆分为5个键,每个键的每个字节有2个十六进制。然后遍历加密的消息,每次取两个十六进制,转换为字节1-255,用密钥解码一个字节,然后从结果字节生成一个解密字符。对具有相应密钥的字节进行循环解码,以便密钥[0]用于字节[0],密钥[1]:字节[1],然后循环回密钥[0]用于字节[5]。应该只需要两个相当紧凑的while循环。假设这也是一个5通道xor加密。您需要为每个键字节求解。您可以通过迭代0-255中的每个密钥,并找到一个解密的子结果或“通道”来实现这一点,该子结果或“通道”可以最大化ascii表中的可读字符数并最小化不可读字符。太多不可读的字符,而且您不可能在这里假设它是正确的键。在这种情况下,将加密消息拆分为消息“通道”可能会很有用,就像在我回答的第一个代码片段中所做的那样。@Lanhasts:Woah,请稍等片刻!!我几乎放弃了,直到我把频道设置为8个。这是一条关于国家安全局的信息。我将发布解决方案。谢谢!您使用什么来运行javascript?
var cryptmsg="9887702584b28e6c71b7bb997e7195bf817a3884bf98353889fa9f7d34c7bc8a7625c7ae837425cbfa9e7b258eb6cb73308ea8876c7195bf88703f93b69239718eaecb623094fa9b673e85bb897928c798997c2586b3853222c7b88e6625c7b18e6525c7a98e762382aec535058fb398353894fa89703286af98707188bccb613982fa98703295bf886c7194af99673e92b48f7c3f80fa8a793dc7ae83707186b99f7c278eae827022c7b98a67238ebf8f353e89fa83702382fa8f60238eb48c350688a8877171b0bb99350590b5cb623094fa84737191b39f743dc7b386653e95ae8a7b3282fa9f7a7188af99353f86ae827a3f86b6cb663484af997c259efa8a7b35c7af8761388abb9f707191b388613e95a3c5";
var key="daeb1551e7";
var aCryptMsg=Array.prototype.slice.call(cryptmsg);
var aKey=Array.prototype.slice.call(key);
var chanKey=[];
var chanIndex=0;
var aDecryptMsg=[];
function dec(nkey,ncrypt){
    var ndec=nkey^ncrypt;
    return String.fromCharCode(ndec); 
}
while(aKey.length){
  var buffer=aKey.splice(0,2);
  var nkey=parseInt(buffer.join(""),16);
  chanKey.push(nkey);
}
while(aCryptMsg.length){
  var buffer=aCryptMsg.splice(0,2);
  var ncrypt=parseInt(buffer.join(""),16);
  var debuf=dec(chanKey[chanIndex],ncrypt);
  aDecryptMsg.push(debuf);
  chanIndex=(++chanIndex)%5;
}
aDecryptMsg.join("");

/*
Bletchey Park rejoices in the fact that, until fairly recently, it was probably Britain's best kept secret. This is because of the secrecy surrounding all the activities carried on here during World War Two was of vital importance to our national security and ultimate victory.
*/
var cryptmsg="98FE30BEAB569CB886B12CBFB110C9EA84F076FAEE08C4BB80A473F4E906C5E0D1F426FFE901C4EE85A624FCBA55C4EC83A773FEBB02FAD3AEFF65FDBC10BDB893F22DECBA09C7ECCDB131A4EE1080AB8EE12ABFEE54D09DA4C265BBEA43D0A994F329A5F85895BDC1F82BECFF5895F9A7F421A9F9519CF9B3F422A5F84495ABCFB115B9E95C99BAC1F22AA1E6559EAD92B132A9F955D0AB84E030A9F84495BDCDB124A2EF1099B7C1E52DA9AB569FB58DFE32A5E557D0A084F037ECFF479FF98EE120A2AB479FAB8AE22DA3FB43D0AE84E320ECE3559CBDC1E52AECEF5983BA94E236ECFF5895F991E32ABCE44395BDC1E231ADE55491AB85BF6598E35582BCC1E624BFAB439FB484B126BEE24499BA88E228ECED429FB4C1E724BEE25F85AAC1E124BEFF5995AACDB12CA2E85C85BD88FF22ECED429FB4C1E130AEE75993F48AF43CECE84289A995FE22BEEA4098A0C1E12CA3E55595AB92B108ADF94499B7C1D920A0E75D91B7C1F02BA8AB6798B095F72CA9E754D09D88F723A5EE1CD0BA88E52CA2EC1091F992F92ABEFF559EBC85B12EA9F2109CBC8FF631A4AB519EBDC1E52DA9AB5D89AA95F437A5E44583F9C3C268AEE44895AAC3B124BFAB5586B085F42BAFEE109FBFC1F828BCF95F80BC93B12CA2FF5582BF84E320A2E855D0BF93FE28ECFF5895F9AFC204E2AB6498BCC1E230BFFB5993B08EFF65BBEA43D0AD89F031ECFF5895F980FD22A3F95984B18CB12DADEF1092BC84FF65AFE44695AB95FD3CECFC5591B284FF20A8AB5289F995F920ECE25E84BC8DFD2CABEE5E93BCC1F022A9E55389F992FE65B8E35184F995F920B5AB1DD0BB94E565A2E41D9FB784B120A0F855D0F4C1F22AB9E754D0BC80E22CA0F21082BC80F565A9E55382A091E520A8AB5D95AA92F022A9F81ED0988DF02BECC05F9EB184F828ECA35F9EBCC1FE23ECFF5895F985F436A5EC5E95AB92B12AAAAB74B58AC8B126A3E65D95B795F421E0AB12A7BCC1E220A2FF1084B184B116E1E95F88BC92B12AAAED1084B6C1C624BFE3599EBE95FE2BE2AB6498BC98B126ADE655D0BB80F22EECEA5E94F996F437A9AB519CB5C1F52CAAED5582BC8FE56BEEAB6498BCC1C42BA5FF5594F9B2E524B8EE43D08A84FF24B8EE10A3BC8DF426B8AB739FB48CF831B8EE55D0B68FB10CA2FF559CB588F620A2E855D0AB84E72CA9FC5594F995F920ECC563B1FE92B124AFFF599FB792B131A3AB5495AD84E328A5E555D0AE89F431A4EE42D0AD89F437A9AB5891BDC1F320A9E51091B798B12CA1FB429FA984E365A5E5469FB597F428A9E544DEF9A8FF65B8E355D0AC8FF229ADF84399BF88F421ECF8459DB480E33CECE456D0AD89F42CBEAB5699B785F82BABF81CD0A994F329A5F85895BDC1F82BECBA09C7E1CDB131A4EE10B3B68CFC2CB8FF5595F996E32AB8EE0AFAD3C1B165ECC25ED0AD89F465A8EE4695B58EE128A9E544D0B687B10189D81CD097B2D065AFE45E86B08FF220A8AB79B294C1E52DADFF1091F993F421B9E85594F98AF43CECF8598ABCC1E624BFAB4385BF87F826A5EE5E84E2C1F82BA8E24295BA95FD3CECEA4383B092E520A8AB599EF995F920ECEF5586BC8DFE35A1EE5E84F98EF765B8E355D08ACCF32AB4AB4384AB94F231B9F95583E2C1F02BA8AB5395AB95F823A5EE54D0AD89F031ECFF5895F987F82BADE710B49CB2B124A0EC5F82B095F928ECFC5183F5C1E52AECFF5895F983F436B8AB5F96F995F920A5F9109BB78EE629A9EF5795F5C1F737A9EE1096AB8EFC65ADE549D0AA95F031A5F84499BA80FD65A3F9109DB895F920A1EA4499BA80FD65BBEE519BB784E236E2813AB8B696F433A9F91CD0B095B124A0F85FD0BF8EE42BA8AB4498B8959B4FECAB10D097B2D065A8E254D0B78EE565B8EA5D80BC93B132A5FF58D0AD89F465A8EE4399BE8FB12AAAAB4498BCC1F029ABE44299AD89FC65A5E51091B798B132ADF21ED090A3DC65A5E54695B795F421ECEA5E94F985F436A5EC5E95BDC1E52DA9AB519CBE8EE32CB8E35DDCF98CF021A9AB519CB5C1E120BEFF599EBC8FE565A8EE5399AA88FE2BBFAB4295BE80E321A5E557D0B095BD65ADE554D0BA8EFF26B9F94295BDC1E52DADFF1084B184B124ABF95595BDC1E435A3E5109BBC98B136A5F155D0AE80E265A1E44295F995F924A2AB5194BC90E424B8EE1096B693B124A0E71093B68CFC20BEE85991B5C1F035BCE75993B895F82AA2F81096B693B132A4E25398F995F920ECCF75A3F996F036ECE25E84BC8FF520A8A53AFA988FFE31A4EE42D0B484FC27A9F9109FBFC1E52DA9AB74B58AC1E520ADE61CD08E80FD31A9F910A4AC82F928ADE51CD0AA95F031A9EF10D28E84B121A9FD559CB691F421ECFF5895F9A5D416ECEA5C97B693F831A4E61095B795F837A9E749D0AE88E52DA5E510B99BACB130BFE25E97F9A8D308A9F943DEF9B5F920ECC563B1F985F821ECE55F84F985F826B8EA4495F980B136A5E5579CBCC1E62CBEEE11D2F9A8FF65AFE45E84AB80E231E0AB51D0BD84F229ADF84399BF88F421ECC563B1F983FE2AA7AB5F9EF982E33CBCFF5F9CB686F826ECE35983AD8EE33CECF84491AD84E27FC68110D0F9C1D82BECBA09C7EAC1DF079FAB439FB588F22CB8EE54D0A993F833ADFF55D0B08FF530BFFF4289F987FE37ECEA1094B895F065A9E55382A091E52CA3E51083AD80FF21ADF954D0F1A5D416E5A510A4B184B123A5F94384F98EF723A9F9599EBE92B132A9F955D0BD88E224BCFB5F99B795F82BABA71083B6C1DF168DAB5295BE80FF65BBE4429BB08FF665A3E51099AD92B12ABBE51091B586FE37A5FF589DF7C1C52DA9E510B8B696F037A8AB629FAA84FF27A0FE5DDCF985F435B9FF49D0BD88E320AFFF5F82F987FE37ECF95583BC80E326A4AB519EBDC1F42BABE25E95BC93F82BABA71094B092F22ABAEE4295BDC1E52DADFF10A7B88DE520BEAB6485BA89FC24A2AB5F96F9A8D308ECFC5183F996FE37A7E25E97F98EFF65ADAB5D9FBD88F72CAFEA4499B68FB131A3AB7C85BA88F720BEAB569FABC1F620A2EE4291B5C1E436A9A510BE8AA0B122ADFD55D08D94F22DA1EA5ED0B8C1F229A9EA4291B782F465ADE554D0BB93FE30ABE344D0B188FC65A5E51084B6C1E62ABEE0109AB688FF31A0F21087B095F965B8E355D09886F42BAFF2109FB7C1F92CBFAB7C85BA88F720BEAB5D9FBD88F72CAFEA4499B68FBF67C681519EBDEB9B65ECAB10BE8AA0B132A3F95B95BDC1F229A3F8559CA0C1E62CB8E310B99BACB131A3AB4384AB84FF22B8E3559EF995F920ECEA5C97B693F831A4E61091BE80F82BBFFF1091B58DB120B4E85580ADC1F337B9FF55D0BF8EE326A9AB5184AD80F22EBFAB519EBDC1E52AECF84482BC8FF631A4EE5ED0AA94F336B8E24485AD88FE2BECFF5192B584E269ECE8519CB584F5659FA6529FA184E26BECC85F9EAF84E336A9E749DCF9AFC204ECFF4299BC85B131A3AB539FB797F82BAFEE10B99BACB131A3AB4295BD94F220ECFF5895F98DF42BABFF58D0B687B131A4EE109BBC98B123BEE45DD0EFD5B131A3AB04C8F983F831BFA510A5B595F828ADFF559CA0C1E52DA9F21093B68CE137A3E65983BC85B12AA2AB51D0ECD7BC27A5FF109BBC98BF4FC6D85F9DBCC1FE23ECFF5895F992E436BCE25399B68FE265ADE95F85ADC1F92CA8EF559EF996F424A7E55583AA84E265A5E51084B184B116E1E95F88BC92B132A9F955D0B88DFD24B5EE54D0B08FB174F5B200DCF996F831A4AB4498BCC1F82BA8EE4095B785F42BB8AB5499AA82FE33A9F949D0B88FF565A3FB559EF991E427A0E25391AD88FE2BECE949D09C8DF8658EE25891B4C1F02BA8AB7194B0C1C22DADE65982F98EF765A8E25696BC93F42BB8E2519CF982E33CBCFF519EB88DE836A5F81CD0B8C1F620A2EE4291B5C1FC20B8E35F94F987FE37ECE94295B88AF82BABAB529CB682FA65AFE24098BC93E26BECDF5895F9B2BC27A3F35583F98EF76588CE63D0AE84E320ECE64593B1C1FC2ABEEE1082BC92F836B8EA5E84F995FE65B8E355D0B895E524AFE01084B180FF65A5ED1084B184E865A4EA54D0BB84F42BECE8589FAA84FF65ADFF1082B88FF52AA1A71083AD93FE2BABE749D0AA94F622A9F84499B786B131A4EA44D090A3DC65A7E55587F980F32AB9FF1084B184B131A9E8589EB090E420ECE25ED0AD89F465FDB207C0AACFB111A4E243D0AE80E265A5E55495BC85B131A4EE1093B892F47EECE25ED0E8D8A871E0AB749FB7C1D22ABCFB5582AA8CF831A4AB4085BB8DF836A4EE54D0AA8EFC20ECE456D0AD89F465A3F95997B08FF029ECEF5583B086FF65AFF95984BC93F824ECED5F82F995F920ECD81D92B699F436E2AB7193BA8EE321A5E557D0AD8EB116B8EE4695B7C1DD20BAF21CD090A3DC659BEA4483B68FB137A9F85591AB82F920BEF81094B092F22ABAEE4295BDC1F52CAAED5582BC8FE52CADE71093AB98E131ADE5519CA095F826ECEA4484B882FA36ECE25ED0E8D8A671ECEA5E94F996F437A9AB5183B284F565AEF21084B184B10B9FCA1084B6C1FA20A9FB1084B184B131A9E8589EB090E420ECF85593AB84E56BECC85F80A984E336A1E24498F984E935A0EA599EAAC1D80781AC43D0AA84F237A9E849D0BD84F22CBFE25F9EF983E865BFEA4999B786BD65EEFF5891ADC1E624BFAB5295BA80E436A9AB6B94B087F720BEEE5E84B080FD65AFF94980AD80FF24A0F24399AABCB126ADE51092BCC1F065BAEE4289F991FE32A9F95685B5C1E52AA3E71CD0AC92F421ECEA5791B08FE231ECE6519EA0C1E226A4EE5D95AACDB124A2EF1084B184E320ECFC5183F982FE2BAFEE429EF995F924B8AB4385BA89B12CA2ED5F82B480E52CA3E51099B7C1E52DA9AB4085BB8DF826ECEF5F9DB888FF65AFE4459CBDC1F021BAEE4283BC8DE865ADED5695BA95B12BADFF599FB780FD65BFEE5385AB88E53CE2A910BCBC97E865BDFE5F84BC92B112ADE74495ABC1C530AFE35D91B7DBB16797FF6D98BC98B124BFE05594F994E265B8E41083AD80FC35ECEA5C9CF98EE437ECEF5F93AC8CF42BB8F81093B68FF72CA8EE5E84B080FD6BE2A510A7BCC1F026B8FE519CB598B135B9FF1091F98FE428AEEE42D0B68FB120ADE858D0B68FF465ADE554D0B58EF22EA9EF1084B184FC65B9FB1099B7C1E224AAEE43DCF983F426ADFE4395F995F920B5AB4795AB84B126A3E54399BD84E320A8AB65DE8ACFB122A3FD5582B78CF42BB8AB539CB892E22CAAE25594F7C1C52DA9F21083B888F565A8E41099ADCFB116A3AB79D0BD88F565A5FF12DEF9A3E330AFEE10A3BA89FF20A5EE42D0B683E220BEFD5594F995F924B8AB12B9ADC1E52AA3E01084B184B124AFEA5495B488F265AFE45D9DAC8FF831B5AB4487B6C1F520AFEA5495AAC1E52AECED5997AC93F465A3FE44D0AD89F031ECFF5895F9AFC204ECAC4487BC80FA36EBAB5193AD94F029A0F21099B491E32ABAEE54D0AD89F465BFEE5385AB88E53CECE456D09DA4C26BEE";
var aCryptMsg=Array.from(cryptmsg);
var channelCount=8;
var channel=[];
var chanIndex=0;
function dec(nkey,ncrypt){
  var ndec=nkey^ncrypt;
  return ndec;
}

for(var i=0; i<channelCount; i++){
  channel[i]=[];
}
while(aCryptMsg.length){
  var buffer=aCryptMsg.splice(0,2).join("");
  var ncrypt=parseInt(buffer,16);
  channel[chanIndex].push(ncrypt);
  chanIndex=(++chanIndex)%channelCount;
}
var goody=Object.create(null);
var alphanumerics=[[0x30,0x39],[0x41,0x5a],[0x61,0x7a]];
var alphabetical=[[0x41,0x5a],[0x61,0x7a]];
var currentRanges=alphanumerics;
currentRanges.forEach(function(range){
  var indexStart=range[0];
  var indexEnd=range[1];
  for (var i=indexStart; i<=indexEnd; i++){
    //table.push(String.fromCharCode(i));
    var ch=String.fromCharCode(i);
    goody[ch]=1;
  }   
});
(" ,.;:!\"'").split("").forEach(ch=>goody[ch]=1);

function findKeyCandidate(byteArray){
  var keyResults=[];
  for (var key=0; key<256; key++){
    keyResults[key]=0;
    byteArray.forEach(function(ncrypt){
      var ndec=dec(key,ncrypt);
      var dchar=String.fromCharCode(ndec);
      if(goody[dchar]){
        keyResults[key]++;
      }
    });
  }
  keyResults=keyResults.map(function(count,index){
    return {key:index,count:count};
  });
  keyResults.sort(function(a,b){
    return a.count-b.count;
  });
  return keyResults.pop().key;
}

var chanKey=channel.map(findKeyCandidate);
chanIndex=0;
var aDecrypMsg=[];
while(channel[chanIndex].length>0){
  var ncrypt=channel[chanIndex].shift();
  var nkey=chanKey[chanIndex];
  var ndec=dec(nkey,ncrypt);
  aDecrypMsg.push(ndec);
  chanIndex=(++chanIndex)%channelCount;
}
aDecrypMsg.map(function(byte){return String.fromCharCode(byte)}).join("");  
/*
your flag is: 93ea36e84ba568b6590ec3b147d7a01e45b66202

On 17 March 1975, the proposed DES was published in the Federal Register. Public comments were requested, and in the following year two open workshops were held to discuss the proposed standard. There was some criticism from various parties, including from public-key cryptography pioneers Martin Hellman and Whitfield Diffie, citing a shortened key length and the mysterious "S-boxes" as evidence of improper interference from the NSA. The suspicion was that the algorithm had been covertly weakened by the intelligence agency so that they - but no-one else - could easily read encrypted messages. Alan Konheim (one of the designers of DES) commented, "We sent the S-boxes off to Washington. They came back and were all different." The United States Senate Select Committee on Intelligence reviewed the NSA's actions to determine whether there had been any improper involvement. In the unclassified summary of their findings, published in 1978, the Committee wrote:

    In the development of DES, NSA convinced IBM that a reduced key size was sufficient; indirectly assisted in the development of the S-box structures; and certified that the final DES algorithm was, to the best of their knowledge, free from any statistical or mathematical weakness.

However, it also found that

    NSA did not tamper with the design of the algorithm in any way. IBM invented and designed the algorithm, made all pertinent decisions regarding it, and concurred that the agreed upon key size was more than adequate for all commercial applications for which the DES was intended.

Another member of the DES team, Walter Tuchman, stated "We developed the DES algorithm entirely within IBM using IBMers. The NSA did not dictate a single wire!" In contrast, a declassified NSA book on cryptologic history states:

    In 1973 NBS solicited private industry for a data encryption standard (DES). The first offerings were disappointing, so NSA began working on its own algorithm. Then Howard Rosenblum, deputy director for research and engineering, discovered that Walter Tuchman of IBM was working on a modification to Lucifer for general use. NSA gave Tuchman a clearance and brought him in to work jointly with the Agency on his Lucifer modification."

and

    NSA worked closely with IBM to strengthen the algorithm against all except brute force attacks and to strengthen substitution tables, called S-boxes. Conversely, NSA tried to convince IBM to reduce the length of the key from 64 to 48 bits. Ultimately they compromised on a 56-bit key.

Some of the suspicions about hidden weaknesses in the S-boxes were allayed in 1990, with the independent discovery and open publication by Eli Biham and Adi Shamir of differential cryptanalysis, a general method for breaking block ciphers. The S-boxes of DES were much more resistant to the attack than if they had been chosen at random, strongly suggesting that IBM knew about the technique in the 1970s. This was indeed the case; in 1994, Don Coppersmith published some of the original design criteria for the S-boxes. According to Steven Levy, IBM Watson researchers discovered differential cryptanalytic attacks in 1974 and were asked by the NSA to keep the technique secret. Coppersmith explains IBM's secrecy decision by saying, "that was because [differential cryptanalysis] can be a very powerful tool, used against many schemes, and there was concern that such information in the public domain could adversely affect national security." Levy quotes Walter Tuchman: "[t]hey asked us to stamp all our documents confidential... We actually put a number on each one and locked them up in safes, because they were considered U.S. government classified. They said do it. So I did it". Bruce Schneier observed that "It took the academic community two decades to figure out that the NSA 'tweaks' actually improved the security of DES."
*/