public override void SetParameter(Octets param) { Octets k_ipad = new Octets(64); int keylen = param.size(); if (keylen > 64) { Octets key = MD5Hash.Digest(param); k_ipad.replace(key); k_opad.replace(key); keylen = key.size(); } else { k_ipad.replace(param); k_opad.replace(param); } int i = 0; for (; i < keylen; i++) { k_ipad.setByte(i, (byte)(k_ipad.getByte(i) ^ 0x36)); k_opad.setByte(i, (byte)(k_opad.getByte(i) ^ 0x5c)); } for (; i < 64; i++) { k_ipad.setByte(i, (byte)0x36); k_opad.setByte(i, (byte)0x5c); } k_ipad.resize(64); k_opad.resize(64); md5hash.Update(k_ipad); }
public override Octets Update(Octets o) { int len = o.size(); for (int i = 0; i < len; i++) { index2 += perm[(++index1) & 0xff]; byte k = perm[index1 & 0xff]; perm[index1 & 0xff] = perm[index2 & 0xff]; perm[index2 & 0xff] = k; byte j = (byte)(perm[index1 & 0xff] + perm[index2 & 0xff]); o.setByte(i, (byte)(o.getByte(i) ^ perm[j & 0xff])); } return o; }
public override void SetParameter(Octets o) { int keylen = o.size(); byte j = 0; for (int i = 0; i < 256; i++) perm[i] = (byte)i; for (int i = 0; i < 256; i++) { j += perm[i]; j += o.getByte(i % keylen); byte k; k = perm[i]; perm[i] = perm[j & 0xff]; perm[j & 0xff] = k; } index1 = index2 = 0; }