internal static byte[] GetCredentials() { // unique credential should be at least these symbols; comp-name, sid, app-code // obscure the code and shift in file; make it hard to find string user = GetComputerName() + GetUserSid() + "x0024b88t72:im@vtc#s1d1"; using (Keccak256 digest = new Keccak256()) return digest.ComputeHash(Encoding.UTF8.GetBytes(user)); }
private void OnGenerateButtonClick(object sender, EventArgs e) { byte[] data = Encoding.UTF8.GetBytes(txtPassphrase.Text); using (Keccak256 digest = new Keccak256()) Passphrase = digest.ComputeHash(data); this.Hide(); }
internal static byte[] GetDomainId() { string domain = GetDomainName(); if (string.IsNullOrEmpty(domain)) domain = GetComputerName(); int blockSize = domain.Length < 32 ? 32 : domain.Length; byte[] data = new byte[blockSize]; byte[] name = Encoding.UTF8.GetBytes(domain); Buffer.BlockCopy(name, 0, data, 0, name.Length); using (Keccak256 digest = new Keccak256()) return digest.ComputeHash(Encoding.UTF8.GetBytes(domain)); }
internal static byte[] GetOriginId() { string user = GetUserName() + GetUserSid(); byte[] hash; using (Keccak256 digest = new Keccak256()) hash = digest.ComputeHash(Encoding.UTF8.GetBytes(user)); byte[] id = new byte[16]; for (int i = 0, j = 16; i < 16; i++, j++) id[i] = (byte)(hash[i] ^ hash[j]); return id; }