Skip to content

关于解密判断入参IsBase64的优化建议 #330

Open
@hnwywwh

Description

命名空间:VOL.Core.Extensions
类:ObjectExtension
增加方法:IsBase64String
public static bool IsBase64String(this string base64String)
{
const int bitsEncodedPerChar = 6;
int bytesExpected = (base64String.Length * bitsEncodedPerChar) >> 3;
Span bytesBuffer = stackalloc byte[bytesExpected];
return Convert.TryFromBase64String(base64String, bytesBuffer, out int bytesWritten);
}

命名空间:VOL.Core.Extensions
类:SecurityEncDecryptExtensions
方法:DecryptDES
增加入参判断,优于上下文try catch
if (decryptString.IsNullOrWhiteSpace()|| decryptKey.IsNullOrWhiteSpace() || !decryptString.IsBase64String())
{
return decryptString;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions