本文整理汇总了C#中Windows.Storage.Streams.IBuffer类的典型用法代码示例。如果您正苦于以下问题:C# IBuffer类的具体用法?C# IBuffer怎么用?C# IBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IBuffer类属于Windows.Storage.Streams命名空间,在下文中一共展示了IBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Rc4RandomGenerator
public Rc4RandomGenerator(IBuffer key)
{
if (key == null)
throw new ArgumentNullException("key");
_state = new byte[256];
var keyLength = key.Length;
for (uint w = 0; w < 256; ++w)
_state[w] = (byte)w;
unchecked
{
byte j = 0;
uint keyIndex = 0;
for (uint w = 0; w < 256; ++w) // Key setup
{
j += (byte)(_state[w] + key.GetByte(keyIndex));
var temp = _state[0];
_state[0] = _state[j];
_state[j] = temp;
++keyIndex;
if (keyIndex >= keyLength)
keyIndex = 0;
}
}
GetRandomBytes(512);
}
开发者ID:Confuset,项目名称:7Pass-Remake,代码行数:32,代码来源:Rc4RandomGenerator.cs
示例2: EncodeToBase64String
/// <summary>
/// Encodes a buffer to a base64 string.
/// </summary>
/// <param name="buffer">Input buffer.</param>
/// <returns>Base64-encoded output string.</returns>
public static string EncodeToBase64String( IBuffer buffer )
{
if (buffer == null)
throw new ArgumentNullException("buffer");
return Convert.ToBase64String(buffer.ToArray());
}
开发者ID:jvlppm,项目名称:WinRT.NET,代码行数:12,代码来源:CryptographicBuffer.cs
示例3: HashData
public IBuffer HashData (IBuffer data)
{
if (data == null)
return new byte[HashLength].AsBuffer();
return this.context.ComputeHash (data.AsStream()).AsBuffer();
}
开发者ID:ermau,项目名称:WinRT.NET,代码行数:7,代码来源:HashAlgorithmProvider.cs
示例4: Read
uint Read(IBuffer buffer, uint offset, uint count)
{
if (this.needSeek) {
if (this.position < 44)
asap.Seek(0);
else {
ulong bytes = this.position - 44 & ~(BufferSize - 1UL);
asap.SeekSample((int) (bytes / wavHeader[32]));
}
this.needSeek = false;
}
ulong left = this.size - this.position;
if (count > left)
count = (uint) left;
if (this.position < 44UL) {
uint n = Math.Min(44 - (uint) this.position, count);
this.wavHeader.CopyTo((int) this.position, buffer, offset, (int) n);
this.position += n;
offset += n;
count -= n;
}
while (count > 0) {
int i = (int) this.position - 44 & BufferSize - 1;
if (i == 0)
asap.Generate(this.samples, BufferSize, ASAPSampleFormat.S16LE);
uint n = Math.Min((uint) BufferSize - (uint) i, count);
this.samples.CopyTo(i, buffer, offset, (int) n);
this.position += n;
offset += n;
count -= n;
}
return offset;
}
开发者ID:hudokkow,项目名称:audiodecoder.asap,代码行数:34,代码来源:MetroASAP.cs
示例5: Decrypt
/// <summary>
/// Decrypts the specified input stream.
/// </summary>
/// <param name="input">The input stream.</param>
/// <param name="masterKey">The master key.</param>
/// <param name="masterSeed">The master seed.</param>
/// <param name="encryptionIV">The encryption initialization vector.</param>
/// <returns>The decrypted buffer.</returns>
/// <exception cref="ArgumentNullException">
/// The <paramref name="input"/>, <paramref name="masterSeed"/>, <paramref name="masterKey"/>
/// and <paramref name="encryptionIV"/> cannot be <c>null</c>.
/// </exception>
public static async Task<IInputStream> Decrypt(IRandomAccessStream input,
IBuffer masterKey, IBuffer masterSeed, IBuffer encryptionIV)
{
if (input == null) throw new ArgumentNullException("input");
if (masterSeed == null) throw new ArgumentNullException("masterSeed");
if (masterKey == null) throw new ArgumentNullException("masterKey");
if (encryptionIV == null) throw new ArgumentNullException("encryptionIV");
var sha = HashAlgorithmProvider
.OpenAlgorithm(HashAlgorithmNames.Sha256)
.CreateHash();
sha.Append(masterSeed);
sha.Append(masterKey);
var seed = sha.GetValueAndReset();
var aes = SymmetricKeyAlgorithmProvider
.OpenAlgorithm(SymmetricAlgorithmNames.AesCbcPkcs7)
.CreateSymmetricKey(seed);
var buffer = WindowsRuntimeBuffer.Create(
(int)(input.Size - input.Position));
buffer = await input.ReadAsync(buffer, buffer.Capacity);
buffer = CryptographicEngine.Decrypt(aes, buffer, encryptionIV);
var stream = new InMemoryRandomAccessStream();
await stream.WriteAsync(buffer);
stream.Seek(0);
return stream;
}
开发者ID:Confuset,项目名称:7Pass-Remake,代码行数:43,代码来源:FileFormat.cs
示例6: SaveToPicturesLibrary
public void SaveToPicturesLibrary(IBuffer imageBuffer, [CallerMemberName] string fileName = "", [CallerFilePath]string callerFilePath = "")
{
fileName = Path.GetFileNameWithoutExtension(callerFilePath) + "_" + fileName;
if (!Path.HasExtension(fileName))
{
fileName = Path.ChangeExtension(fileName, "jpg");
}
lock (m_lockObject)
{
if (m_isClosed)
{
throw new InvalidOperationException("ImageResults closed, cannot queue more operations.");
}
m_saveTask = m_saveTask.ContinueWith(async _ =>
{
m_stopwatch.Start();
var file = await m_folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting).AsTask().ConfigureAwait(false);
await FileIO.WriteBufferAsync(file, imageBuffer).AsTask().ConfigureAwait(false);
m_stopwatch.Stop();
});
}
}
开发者ID:nagyistoce,项目名称:Lumia-Imaging-SDK-Extras,代码行数:29,代码来源:ImageResults.cs
示例7: GetNewFrameAndApplyEffect
public async Task GetNewFrameAndApplyEffect(IBuffer frameBuffer, Size frameSize)
{
if (_semaphore.WaitOne(500))
{
var scanlineByteSize = (uint)frameSize.Width * 4; // 4 bytes per pixel in BGRA888 mode
var bitmap = new Bitmap(frameSize, ColorMode.Bgra8888, scanlineByteSize, frameBuffer);
try
{
if (_blendEffect != null)
{
_blendEffect.GlobalAlpha = GlobalAlpha;
var renderer = new BitmapRenderer(_blendEffect, bitmap);
await renderer.RenderAsync();
}
else
{
var renderer = new BitmapRenderer(_cameraPreviewImageSource, bitmap);
await renderer.RenderAsync();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("RealtimeBlendDemo.GetNewFrameAndApplyEffect(): "
+ ex.ToString());
}
_semaphore.Release();
}
}
开发者ID:roachhd,项目名称:real-time-blend-demo,代码行数:31,代码来源:Effects.cs
示例8: Encrypt
public static IBuffer Encrypt(IBuffer data,
CryptographicKey key,
out IBuffer iv,
String AlgorithmName = null)
{
//declares
var strAlgName = AlgorithmName != null ? AlgorithmName : DefaultAlgorithm;
iv = null;
// Open a symmetric algorithm provider for the specified algorithm.
var objAlg = SymmetricKeyAlgorithmProvider.OpenAlgorithm(strAlgName);
// Determine whether the message length is a multiple of the block length.
// This is not necessary for PKCS #7 algorithms which automatically pad the
// message to an appropriate length.
if (!strAlgName.Contains("PKCS7"))
{
if ((data.Length % objAlg.BlockLength) != 0)
throw new Exception("Message buffer length must be multiple of block length.");
}
// CBC algorithms require an initialization vector. Here, a random
// number is used for the vector.
if (strAlgName.Contains("CBC"))
iv = CryptographicBuffer.GenerateRandom(objAlg.BlockLength);
// Encrypt the data and return.
return CryptographicEngine.Encrypt(key, data, iv);
}
开发者ID:yodiwo,项目名称:plegma,代码行数:29,代码来源:CryptoEngine.Universal.cs
示例9: GetNewFrameAndApplyEffect
public async Task GetNewFrameAndApplyEffect(IBuffer frameBuffer, Size frameSize)
{
if (_semaphore.WaitOne(500))
{
var scanlineByteSize = (uint)frameSize.Width * 4; // 4 bytes per pixel in BGRA888 mode
var bitmap = new Bitmap(frameSize, ColorMode.Bgra8888, scanlineByteSize, frameBuffer);
if (_filterEffect != null)
{
var renderer = new BitmapRenderer(_filterEffect, bitmap);
await renderer.RenderAsync();
}
else if (_customEffect != null)
{
var renderer = new BitmapRenderer(_customEffect, bitmap);
await renderer.RenderAsync();
}
else
{
var renderer = new BitmapRenderer(_cameraPreviewImageSource, bitmap);
await renderer.RenderAsync();
}
_semaphore.Release();
}
}
开发者ID:Rob-Kachmar,项目名称:real-time-filter-demo,代码行数:26,代码来源:NokiaImagingSDKEffects.cs
示例10: ReadAsync_MemoryStream
internal static IAsyncOperationWithProgress<IBuffer, UInt32> ReadAsync_MemoryStream(Stream stream, IBuffer buffer, UInt32 count)
{
Debug.Assert(stream != null);
Debug.Assert(stream is SREMemoryStream);
Debug.Assert(stream.CanRead);
Debug.Assert(stream.CanSeek);
Debug.Assert(buffer != null);
Debug.Assert(buffer is IBufferByteAccess);
Debug.Assert(0 <= count);
Debug.Assert(count <= Int32.MaxValue);
Debug.Assert(count <= buffer.Capacity);
Contract.EndContractBlock();
// We will return a different buffer to the user backed directly by the memory stream (avoids memory copy).
// This is permitted by the WinRT stream contract.
// The user specified buffer will not have any data put into it:
buffer.Length = 0;
SREMemoryStream memStream = stream as SREMemoryStream;
Debug.Assert(memStream != null);
try
{
IBuffer dataBuffer = memStream.GetWindowsRuntimeBuffer((Int32)memStream.Position, (Int32)count);
if (dataBuffer.Length > 0)
memStream.Seek(dataBuffer.Length, SeekOrigin.Current);
return AsyncInfo.CreateCompletedOperation<IBuffer, UInt32>(dataBuffer);
}
catch (Exception ex)
{
return AsyncInfo.CreateFaultedOperation<IBuffer, UInt32>(ex);
}
} // ReadAsync_MemoryStream
开发者ID:dotnet,项目名称:corefx,代码行数:34,代码来源:StreamOperationsImplementation.cs
示例11: ReadAsync
public IAsyncOperationWithProgress<IBuffer, uint> ReadAsync (IBuffer buffer, uint count, InputStreamOptions options)
{
if (disposed)
throw new ObjectDisposedException(GetType().FullName);
throw new NotImplementedException();
}
开发者ID:jvlppm,项目名称:WinRT.NET,代码行数:7,代码来源:StreamToInputStreamAdapter.cs
示例12: CipherEncryption
/// <summary>
/// 对字符串依据指定的算法和密钥进行加密,如果使用 CBC 算法,还需要初始化向量
/// </summary>
/// <param name="content">源字符串</param>
/// <param name="strAlgName">加密算法</param>
/// <param name="encoding">字符串编码方式</param>
/// <param name="key">密钥</param>
/// <param name="iniVec">CBC 初始化向量</param>
/// <returns></returns>
public static IBuffer CipherEncryption(string content, string strAlgName,
BinaryStringEncoding encoding, CryptographicKey key, IBuffer iniVec = null)
{
// Create a buffer that contains the encoded message to be encrypted.
IBuffer buffContent = CryptographicBuffer.ConvertStringToBinary(content, encoding);
// Open a symmetric algorithm provider for the specified algorithm.
SymmetricKeyAlgorithmProvider objAlg = SymmetricKeyAlgorithmProvider.OpenAlgorithm(strAlgName);
// Determine whether the message length is a multiple of the block length.
// This is not necessary for PKCS #7 algorithms which automatically pad the
// message to an appropriate length.
if (!strAlgName.Contains("PKCS7"))
{
if ((buffContent.Length % objAlg.BlockLength) != 0)
{
throw new Exception("Message buffer length must be multiple of block length.");
}
}
if (strAlgName.Contains("CBC") && iniVec == null)
{
throw new ArgumentException("Using CBC Encryption, initial vector must have value");
}
// Encrypt the data and return.
IBuffer buffEncrypt = CryptographicEngine.Encrypt(key, buffContent, iniVec);
return buffEncrypt;
}
开发者ID:aurora-lzzp,项目名称:Aurora-Weather,代码行数:37,代码来源:CryptoHelper.cs
示例13: PixelBufferInfo
public PixelBufferInfo(IBuffer pixelBuffer)
{
this.pixelStream = WindowsRuntimeBufferExtensions.AsStream(pixelBuffer);
this.Bytes = new byte[this.pixelStream.Length];
this.pixelStream.Seek(0L, SeekOrigin.Begin);
this.pixelStream.Read(this.Bytes, 0, this.Bytes.Length);
}
开发者ID:vnktajay,项目名称:Dewinter08142013,代码行数:7,代码来源:IBufferExtensions.cs
示例14: SetAsync
public virtual async Task SetAsync(string key, IBuffer buffer, DateTime expires)
{
try
{
var names = key.Split('\\');
var folder = rootFolder;
for (int i = 0; i < names.Length - 1; i++)
{
folder = await folder.CreateFolderAsync(names[i], CreationCollisionOption.OpenIfExists);
}
var file = await folder.CreateFileAsync(names[names.Length - 1], CreationCollisionOption.ReplaceExisting);
await FileIO.WriteBufferAsync(file, buffer);
// Use ImageProperties.DateTaken to store expiration date
var imageProperties = await file.Properties.GetImagePropertiesAsync();
imageProperties.DateTaken = expires;
await imageProperties.SavePropertiesAsync();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
开发者ID:huoxudong125,项目名称:XamlMapControl,代码行数:25,代码来源:ImageFileCache.cs
示例15: DecrypMode
/// <summary>
/// Дешифрования текст
/// </summary>
/// <param name="SourceText">Исходный (шифрованный) текст</param>
/// <param name="InputKey">Ключ шифрования</param>
/// <param name="AlgorytmName">Имя алгоритма дешифрования</param>
///
/// <returns>Расшифрованный (открытый) текст</returns>
public string DecrypMode(string SourceText, string InputKey, string AlgorytmName, string IV, string KeySize)
{
SymmetricKeyAlgorithmProvider Algorithm = SymmetricKeyAlgorithmProvider.OpenAlgorithm(AlgorytmName);
IBuffer KeyBuffer = CryptographicBuffer.ConvertStringToBinary(InputKey, BinaryStringEncoding.Utf16LE);
IBuffer saltBuffer = CryptographicBuffer.ConvertStringToBinary("[email protected]:Annc!6002mz", BinaryStringEncoding.Utf16LE);
//CryptoKey = Algorithm.CreateSymmetricKey(keymaterial);
KeyDerivationAlgorithmProvider keyDerivationProvider = KeyDerivationAlgorithmProvider.OpenAlgorithm(KeyDerivationAlgorithmNames.Pbkdf2Sha512);
KeyDerivationParameters pbkdf2Parms = KeyDerivationParameters.BuildForPbkdf2(saltBuffer, 10000);
CryptographicKey keyOriginal = keyDerivationProvider.CreateKey(KeyBuffer);
IBuffer keyMaterial = CryptographicEngine.DeriveKeyMaterial(keyOriginal, pbkdf2Parms,Convert.ToUInt32(KeySize)/8);
// string test= CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf16LE, keyMaterial);
CryptoKey = Algorithm.CreateSymmetricKey(keyMaterial);
if (AlgorytmName.Contains("CBC"))
{
IVBuffer = CryptographicBuffer.ConvertStringToBinary(IV, BinaryStringEncoding.Utf16LE);
}
// Set the data to encrypt.
SourceTextBuffer = CryptographicBuffer.DecodeFromBase64String(SourceText);
// Decrypt
DecryptBuffer = Windows.Security.Cryptography.Core.CryptographicEngine.Decrypt(CryptoKey, SourceTextBuffer, IVBuffer);
DecryptTextOutput = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf16LE, DecryptBuffer);//Надо думать над реализацией Base64
return DecryptTextOutput;
}
开发者ID:rachmann,项目名称:CryptoBox,代码行数:40,代码来源:Cryptobox.cs
示例16: OnValueChanged
protected override void OnValueChanged(IBuffer buffer)
{
DataReader wReader = DataReader.FromBuffer(buffer);
using (wReader)
{
byte[] b = new byte[4];
wReader.ReadBytes(b);
var ambientTemperature = BitConverter.ToInt16(b, 2) / 128.0;
double Vobj2 = BitConverter.ToInt16(b, 0);
Vobj2 *= 0.00000015625;
double Tdie = ambientTemperature + 273.15;
double S0 = 5.593E-14;
double a1 = 1.75E-3;
double a2 = -1.678E-5;
double b0 = -2.94E-5;
double b1 = -5.7E-7;
double b2 = 4.63E-9;
double c2 = 13.4;
double Tref = 298.15;
double S = S0 * (1 + a1 * (Tdie - Tref) + a2 * Math.Pow((Tdie - Tref), 2));
double Vos = b0 + b1 * (Tdie - Tref) + b2 * Math.Pow((Tdie - Tref), 2);
double fObj = (Vobj2 - Vos) + c2 * Math.Pow((Vobj2 - Vos), 2);
double tObj = Math.Pow(Math.Pow(Tdie, 4) + (fObj / S), .25);
//CurrentTemperature = tObj - 273.15;
// On retourne plutôt le température ambiante, plus réaliste que temp courante.
CurrentTemperature = ambientTemperature;
}
}
开发者ID:JMLIT,项目名称:WP8Meteo,代码行数:34,代码来源:TemperatureSensor.cs
示例17: Decrypt
public static IBuffer Decrypt(IBuffer input, string password = "<tg5Xtq{>w4<7HU}#AXhlklkh213a.,2s~!2???DAAAIHATETHISOS")
{
var iv = CreateInitializationVector(password);
var key = CreateKey(password);
var decryptedBuffer = CryptographicEngine.Decrypt(
key, input, iv);
return decryptedBuffer;
}
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:8,代码来源:EncryptionProvider.cs
示例18: CopyTo
public static void CopyTo(this Byte[] source, IBuffer destination)
{
if (source == null) throw new ArgumentNullException("source");
if (destination == null) throw new ArgumentNullException("destination");
Contract.EndContractBlock();
CopyTo(source, 0, destination, 0, source.Length);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:WindowsRuntimeBufferExtensions.cs
示例19: ToBytes
public static byte[] ToBytes(IBuffer value)
{
if(value == null)
throw new ArgumentException();
var temp = new byte[value.Length];
DataReader.FromBuffer(value).ReadBytes(temp);
return temp;
}
开发者ID:LarryPavanery,项目名称:Windows-nRF-Toolbox,代码行数:8,代码来源:File.cs
示例20: ReadBufferToBytes
// Gets a byte array from a buffer
public static byte[] ReadBufferToBytes(IBuffer buffer)
{
var dataLength = buffer.Length;
var data = new byte[dataLength];
var reader = DataReader.FromBuffer(buffer);
reader.ReadBytes(data);
return data;
}
开发者ID:modulexcite,项目名称:events,代码行数:9,代码来源:BasicParsers.cs
注:本文中的Windows.Storage.Streams.IBuffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论