public void Base32BytesTest() { var byteArray = Encoding.UTF8.GetBytes("Alex LEWIS"); var baseVal = BaseConv.ToBase32(byteArray); var originalByteArray = BaseConv.FromBase32(baseVal); var originalVal = Encoding.UTF8.GetString(originalByteArray); Assert.Equal("Alex LEWIS", originalVal); }
public static byte[] GetBytes(this CipherTextTypes signatureTextType, string signature, Encoding encoding = default, Func <string, byte[]> customCipherTextConverter = null) { encoding = encoding.SafeEncodingValue(); return(signatureTextType switch { CipherTextTypes.PlainText => encoding.GetBytes(signature), CipherTextTypes.Base32Text => BaseConv.FromBase32(signature), CipherTextTypes.Base64Text => BaseConv.FromBase64(signature), CipherTextTypes.Base91Text => BaseConv.FromBase91(signature), CipherTextTypes.Base256Text => BaseConv.FromBase256(signature), CipherTextTypes.ZBase32Text => BaseConv.FromZBase32(signature), CipherTextTypes.Hex => Org.BouncyCastle.Utilities.Encoders.Hex.Decode(signature), _ => customCipherTextConverter is null?encoding.GetBytes(signature) : customCipherTextConverter(signature) });