private static int decryptStatus(byte[] status, int counter) { int ret = -1; string s; byte[] tempData = new byte[64]; byte[] decryptKey = Encoding.UTF8.GetBytes("----KEY_HERE----"); byte[] decryptIV = Encoding.UTF8.GetBytes("-----IV_HERE----"); int neg = -1; decryptIV[(counter % 16)]++; Aes128CounterMode amD; ICryptoTransform ictD; amD = new Aes128CounterMode(decryptIV); ictD = amD.CreateDecryptor(decryptKey, null); ictD.TransformBlock(status, 0, 64, tempData, 0); s = System.Text.Encoding.UTF8.GetString(tempData); neg = s.IndexOf("-"); if (neg != -1) { Int32.TryParse(s.Substring(neg), out ret); } else { Int32.TryParse(s, out ret); } return(ret); }
private static byte[] decryptData(byte[] data, int counter) { string s; byte[] decrypted = new byte[1024]; byte[] decryptKey = Encoding.UTF8.GetBytes("----KEY_HERE----"); byte[] decryptIV = Encoding.UTF8.GetBytes("-----IV_HERE----"); decryptIV[(counter % 16)]++; Aes128CounterMode amD; ICryptoTransform ict; amD = new Aes128CounterMode(decryptIV); ict = amD.CreateDecryptor(decryptKey, null); ict.TransformBlock(data, 0, 1024, decrypted, 0); s = System.Text.Encoding.UTF8.GetString(decrypted); return(decrypted); }