public static string ToBase64String(string value, Encoding encoding, bool omitPaddingCharacters = true) { if (encoding == null) { throw new ArgumentNullException("encoding"); } var valueBuffer = encoding.GetBytes(value); return(Base64Encoding.ToBase64String(valueBuffer, omitPaddingCharacters)); }
public static string FromBase64StringToEncoding(string value, Encoding encoding) { if (encoding == null) { throw new ArgumentNullException("encoding"); } var buffer = Base64Encoding.FromBase64StringToBuffer(value); return(encoding.GetString(buffer)); }
public static string ComputeHash(string value) { if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException("value"); } var buffer = Encoding.UTF8.GetBytes(value); var hash = ConcurrentMD5.ComputeHash(buffer); return(Base64Encoding.ToBase64String(hash)); }
public static string ComputeHash(Stream inputStream) { if (inputStream == null) { throw new ArgumentNullException("inputStream"); } if (ConcurrentSHA1.threadLocalSHA1 == null) { ConcurrentSHA1.threadLocalSHA1 = SHA1.Create(); } var hashBuffer = ConcurrentSHA1.threadLocalSHA1.ComputeHash(inputStream); return(Base64Encoding.ToBase64String(hashBuffer)); }
public static string ToBase64String(string value, bool omitPaddingCharacters = true) { return(Base64Encoding.ToBase64String(value, Encoding.UTF8, omitPaddingCharacters)); }
public static string FromBase64StringToUTF8(string value) { return(Base64Encoding.FromBase64StringToEncoding(value, Encoding.UTF8)); }