有高手可以詳細解釋一下下面這段代碼的演算法嗎,是用什么演算法將字串"BF6W3A776"分解成C, c, D, d, B各個變數的。只看懂了異或,像位與&15,左移位<<4都是什么演算法?還有如何反過來將C, c, D, d, B生成"BF6W3A776"?謝謝。
string str = "BF6W3A776";
byte C, c, D, d, B;
byte[] bytes = new ASCIIEncoding().GetBytes("m@nq&3$r3T@i1rM#");
int num4 = ("0123456789ABCDEFGHJKLMNPQRTUVWXY".IndexOf(str[0]) ^ bytes[4 % bytes.Length]) & 15;
for (int i = 0; i < 4; i++)
{
if ((num4 & (1 << (i & 0x1f))) != 0)
{
int index = "0123456789ABCDEFGHJKLMNPQRTUVWXY".IndexOf(str[(i * 2) + 1]);
int num3 = (("0123456789ABCDEFGHJKLMNPQRTUVWXY".IndexOf(str[(i * 2) + 2]) << 4) + index) ^ bytes[i % bytes.Length];
if (i == 3)
{
C = (byte)((num3 & 240) >> 4); //1
d = (byte)(num3 & 15); //6
}
else if (i == 2)
{
D = (byte)num3; //20
}
else if (i == 1)
{
c = (byte)num3;
}
else if (i == 0)
{
B = (byte)num3;
}
}
}
uj5u.com熱心網友回復:
應該是hash演算法把應該不能回傳的
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/40121.html
標籤:數據結構與算法
