Beispiel #1
0
        public static TResult ExecuteWithSecureString <TResult, TContext>(SecureString secureString, Encoding encoding, TContext context, Func <byte[], TContext, TResult> action)
        {
            ThrowHelpers.CheckNull(nameof(encoding), encoding);
            ThrowHelpers.CheckNull(nameof(action), action);

            if (secureString == null)
            {
                return(action.Invoke(null, context));
            }
            else
            {
                return(ExecuteWithSecureStringInternal <TResult, TContext>(secureString, encoding, context, action));
            }
        }
Beispiel #2
0
        public static TResult ExecuteWithSecureString <TResult>(SecureString secureString, Encoding encoding, Func <byte[], TResult> action)
        {
            ThrowHelpers.CheckNull(nameof(encoding), encoding);
            ThrowHelpers.CheckNull(nameof(action), action);

            if (secureString == null)
            {
                return(action.Invoke(null));
            }
            else
            {
                return(ExecuteWithSecureStringInternal <TResult, int>(secureString, encoding, 0, (buffer, ctx) => action(buffer)));
            }
        }
Beispiel #3
0
        public static void ExecuteWithSecureString(SecureString secureString, Encoding encoding, Action <byte[]> action)
        {
            ThrowHelpers.CheckNull(nameof(encoding), encoding);
            ThrowHelpers.CheckNull(nameof(action), action);

            if (secureString == null)
            {
                action.Invoke(null);
            }
            else
            {
                ExecuteWithSecureStringInternal <int, int>(secureString, encoding, 0, (buffer, ctx) =>
                {
                    action.Invoke(buffer);
                    return(0);
                });
            }
        }
Beispiel #4
0
 public static byte[] GetBytes(string hexValue)
 {
     ThrowHelpers.CheckNull(nameof(hexValue), hexValue);
     return(GetBytes(hexValue.AsSpan()));
 }