update 20251113
This commit is contained in:
39
Client - Kopie/Helper/Strings.cs
Normal file
39
Client - Kopie/Helper/Strings.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public static class Strings
|
||||
{
|
||||
public static string Right(this string value, int length)
|
||||
{
|
||||
if (String.IsNullOrEmpty(value)) return string.Empty;
|
||||
|
||||
return value.Length <= length ? value : value.Substring(value.Length - length);
|
||||
}
|
||||
|
||||
public static string Left(this string value, int maxLength)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return value;
|
||||
maxLength = Math.Abs(maxLength);
|
||||
|
||||
return (value.Length <= maxLength
|
||||
? value
|
||||
: value.Substring(0, maxLength)
|
||||
);
|
||||
}
|
||||
public static string Base64Encode(string plainText)
|
||||
{
|
||||
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
|
||||
return System.Convert.ToBase64String(plainTextBytes);
|
||||
}
|
||||
public static string Base64Decode(string base64EncodedData)
|
||||
{
|
||||
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
|
||||
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user