public void EncryptionShouldWorkCorrect() { // Arrange using (var csp = new RSACryptoServiceProvider(AlgorithmConstants.KeySize)) { var pubKey = csp.ExportParameters(false); var privKey = csp.ExportParameters(true); var str = "helloworld"; // Act var encoded = _service.Encode(str, pubKey); var decoded = _service.Decode(encoded, privKey); // Assert decoded.ShouldBe(str); } }
public static bool IsKeyValid() { string uuid = ""; string key = ""; ReadAuthentication(out uuid, out key); if (string.IsNullOrEmpty(uuid) || string.IsNullOrEmpty(key)) return false; string encodedSN = EncryptService.Encode(uuid); string decoded = EncryptService.Decode(key); return string.Compare(encodedSN, key, StringComparison.Ordinal) == 0; }
private static string MAC() { ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc = mc.GetInstances(); string MACAddress = String.Empty; foreach (ManagementObject mo in moc) { if (MACAddress == String.Empty) // only return MAC Address from first card { bool enabled = (bool)mo["IPEnabled"]; MACAddress = mo["MacAddress"].ToString(); } mo.Dispose(); } MACAddress = MACAddress.Replace(":", ""); return EncryptService.Encode(MACAddress); }