本文整理汇总了C#中System.IO.Stream.ToBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ToBytes方法的具体用法?C# Stream.ToBytes怎么用?C# Stream.ToBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了Stream.ToBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveBlob
public void SaveBlob(string container, string key, Stream bloblStream)
{
lock (_lockObject)
GetBlob(container).AddOrReplace(key, bloblStream.ToBytes());
}
示例2: EncryptStream
/// <summary>
/// 대칭형 암호화 알고리즘을 이용하여, <paramref name="plainStream"/>을 암호화하여 스트림으로 반환합니다.
/// </summary>
/// <param name="encryptor">대칭형 암호화 인스턴스</param>
/// <param name="plainStream">원본 스트림</param>
/// <returns>암호화된 스트림</returns>
public static Stream EncryptStream(this ISymmetricEncryptor encryptor, Stream plainStream) {
plainStream.ShouldNotBeNull("plainStream");
return new MemoryStream(encryptor.Encrypt(plainStream.ToBytes()));
}
示例3: DecryptStream
/// <summary>
/// 암호화된 스트림을 복원합니다.
/// </summary>
/// <param name="encryptor"></param>
/// <param name="stream"></param>
/// <returns></returns>
public static Stream DecryptStream(this ISymmetricEncryptor encryptor, Stream stream) {
return new MemoryStream(encryptor.Decrypt(stream.ToBytes()));
}
示例4: DecryptString
/// <summary>
/// 대칭형 암호화 알고리즘을 이용하여, <paramref name="cipherStream"/>을 복호화한 스트림을 반환합니다.
/// </summary>
/// <param name="encryptor">대칭형 암호화 인스턴스</param>
/// <param name="cipherStream">암호화된 정보를 가진 스트림</param>
/// <returns>복호화된 정보를 가진 스트림</returns>
public static Stream DecryptString(this ISymmetricEncryptor encryptor, Stream cipherStream) {
cipherStream.ShouldNotBeNull("cipherStream");
return new MemoryStream(encryptor.Decrypt(cipherStream.ToBytes()));
}
示例5: CompressStream
/// <summary>
/// 스트림을 압축한다.
/// </summary>
/// <param name="compressor"><see cref="ICompressor"/> 구현 객체</param>
/// <param name="stream">압축할 <see cref="Stream"/></param>
/// <returns>압축된 <see cref="MemoryStream"/></returns>
public static Stream CompressStream(this ICompressor compressor, Stream stream) {
return new MemoryStream(compressor.Compress(stream.ToBytes()));
}