mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
simplify Guid description switch + update devdocs
This commit is contained in:
parent
7f1f08fd68
commit
07edf94bbd
@ -1,6 +1,6 @@
|
||||
# Value Generator Plugin
|
||||
|
||||
The Value Generator plugin is used to generate hashes for strings, to calculate base64 encodings, escape and encode URLs/URIs and to generate GUIDs versions 1, 3, 4 and 5.
|
||||
The Value Generator plugin is used to generate hashes for strings, to calculate base64 encodings, escape and encode URLs/URIs and to generate GUIDs of version 1, 3, 4, 5, and 7.
|
||||
|
||||
![Image of Value Generator plugin](/doc/images/launcher/plugin/community.valuegenerator.png)
|
||||
|
||||
@ -34,7 +34,10 @@ The Value Generator plugin is used to generate hashes for strings, to calculate
|
||||
|
||||
### [`GUIDGenerator`](/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.ValueGenerator/Generators/GUID/GUIDGenerator.cs)
|
||||
- Utility class for generating or calculating GUIDs
|
||||
- Generating GUID versions 1 and 4 is done using builtin APIs. [`UuidCreateSequential`](https://learn.microsoft.com/en-us/windows/win32/api/rpcdce/nf-rpcdce-uuidcreatesequential) for version 1 and `System.Guid.NewGuid()` for version 4
|
||||
- Generating GUID versions 1, 4, and 7 is done using builtin APIs:
|
||||
- [`UuidCreateSequential`](https://learn.microsoft.com/en-us/windows/win32/api/rpcdce/nf-rpcdce-uuidcreatesequential) for version 1
|
||||
- `System.Guid.NewGuid()` for version 4
|
||||
- `System.Guid.CreateVersion7()` for version 7
|
||||
- Versions 3 and 5 take two parameters, a namespace and a name
|
||||
- The namespace must be a valid GUID or one of the [predefined ones](https://datatracker.ietf.org/doc/html/rfc4122#appendix-C)
|
||||
- The `PredefinedNamespaces` dictionary contains aliases for the predefined namespaces
|
||||
|
@ -3,7 +3,6 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using WinRT;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.ValueGenerator.GUID
|
||||
@ -19,36 +18,15 @@ namespace Community.PowerToys.Run.Plugin.ValueGenerator.GUID
|
||||
|
||||
private int Version { get; set; }
|
||||
|
||||
public string Description
|
||||
public string Description => Version switch
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Version)
|
||||
{
|
||||
case 1:
|
||||
return "Version 1: Time base GUID";
|
||||
case 3:
|
||||
case 5:
|
||||
string hashAlgorithm;
|
||||
if (Version == 3)
|
||||
{
|
||||
hashAlgorithm = HashAlgorithmName.MD5.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
hashAlgorithm = HashAlgorithmName.SHA1.ToString();
|
||||
}
|
||||
|
||||
return $"Version {Version} ({hashAlgorithm}): Namespace and name based GUID.";
|
||||
case 4:
|
||||
return "Version 4: Randomly generated GUID";
|
||||
case 7:
|
||||
return "Version 7: Time-ordered randomly generated GUID";
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
1 => "Version 1: Time base GUID",
|
||||
3 => $"Version 3 ({HashAlgorithmName.MD5}): Namespace and name based GUID.",
|
||||
4 => "Version 4: Randomly generated GUID",
|
||||
5 => $"Version 5 ({HashAlgorithmName.SHA1}): Namespace and name based GUID.",
|
||||
7 => "Version 7: Time-ordered randomly generated GUID",
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
private Guid? GuidNamespace { get; set; }
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
using Community.PowerToys.Run.Plugin.ValueGenerator.Properties;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user