feat(EncodeType): Enum zur Klassifizierung von Kodierungstypen erstellt.
- Erweiterungsmethoden hinzugefügt, um zu versuchen, String mit out-keyworld zu dekodieren. - Erweiterungsmethode hinzugefügt, um den Typ des Kodierungstyps des dekodierten String-Arrays zu finden.
This commit is contained in:
parent
54e86b421c
commit
6847b74095
9
EnvelopeGenerator.Application/EncodeType.cs
Normal file
9
EnvelopeGenerator.Application/EncodeType.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace EnvelopeGenerator.Application
|
||||||
|
{
|
||||||
|
public enum EncodeType
|
||||||
|
{
|
||||||
|
EnvelopeReceiver,
|
||||||
|
ReadOnly,
|
||||||
|
Undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -68,6 +68,26 @@ namespace EnvelopeGenerator.Application
|
|||||||
return input.IndexOf('=') == -1; // No padding allowed except at the end
|
return input.IndexOf('=') == -1; // No padding allowed except at the end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryDecode(this string encoded, out string[] decoded)
|
||||||
|
{
|
||||||
|
if (!encoded.IsBase64String())
|
||||||
|
{
|
||||||
|
decoded = Array.Empty<string>();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
byte[] bytes = Convert.FromBase64String(encoded);
|
||||||
|
string decodedString = Encoding.UTF8.GetString(bytes);
|
||||||
|
decoded = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EncodeType GetEncodeType(string[] decoded) => decoded.Length switch
|
||||||
|
{
|
||||||
|
2 => EncodeType.EnvelopeReceiver,
|
||||||
|
3 => EncodeType.ReadOnly,
|
||||||
|
_ => EncodeType.Undefined,
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
|
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -80,7 +100,7 @@ namespace EnvelopeGenerator.Application
|
|||||||
return (null, null);
|
return (null, null);
|
||||||
}
|
}
|
||||||
byte[] bytes = Convert.FromBase64String(envelopeReceiverId);
|
byte[] bytes = Convert.FromBase64String(envelopeReceiverId);
|
||||||
string decodedString = System.Text.Encoding.UTF8.GetString(bytes);
|
string decodedString = Encoding.UTF8.GetString(bytes);
|
||||||
string[] parts = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
string[] parts = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||||
|
|
||||||
if (parts.Length > 1)
|
if (parts.Length > 1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user