public static void CreateNew(string path, string opName, string userName, string password, AccessType access, byte[] opKey, bool globalIM) { OpUser user = new OpUser(path, password); user.Settings.Operation = opName; user.Settings.UserName = userName; user.Settings.KeyPair = new RSACryptoServiceProvider(1024); user.Settings.FileKey = Utilities.GenerateKey(new RNGCryptoServiceProvider(), 256); user.Settings.OpAccess = access; user.Settings.Security = SecurityLevel.Medium; user.Settings.GlobalIM = globalIM; // joining/creating public if (access == AccessType.Public) { // 256 bit rijn SHA256Managed sha256 = new SHA256Managed(); user.Settings.OpKey = sha256.ComputeHash(UTF8Encoding.UTF8.GetBytes(opName.ToLowerInvariant())); user.Settings.Security = SecurityLevel.Low; } // invite to private/secret else if (opKey != null) { user.Settings.OpKey = opKey; } // creating private/secret else if (globalIM) { user.Settings.OpKey = DhtNetwork.GlobalIMKey; } else { user.Settings.OpKey = Utilities.GenerateKey(new RNGCryptoServiceProvider(), 256); } user.Save(); // throws exception on failure }
public static void CreateNew(string path, string opName, string userName, string password, AccessType access, byte[] opKey, bool globalIM) { OpUser user = new OpUser(path, password); user.Settings.Operation = opName; user.Settings.UserName = userName; user.Settings.KeyPair = new RSACryptoServiceProvider(1024); user.Settings.FileKey = Utilities.GenerateKey(new RNGCryptoServiceProvider(), 256); user.Settings.OpAccess = access; user.Settings.Security = SecurityLevel.Medium; user.Settings.GlobalIM = globalIM; // joining/creating public if (access == AccessType.Public) { // 256 bit rijn SHA256Managed sha256 = new SHA256Managed(); user.Settings.OpKey = sha256.ComputeHash(UTF8Encoding.UTF8.GetBytes(opName.ToLowerInvariant())); user.Settings.Security = SecurityLevel.Low; } // invite to private/secret else if (opKey != null) user.Settings.OpKey = opKey; // creating private/secret else if (globalIM) user.Settings.OpKey = DhtNetwork.GlobalIMKey; else user.Settings.OpKey = Utilities.GenerateKey(new RNGCryptoServiceProvider(), 256); user.Save(); // throws exception on failure }