using System;
using System.Runtime.InteropServices;
namespace System.Security.Cryptography
{
/// Converts a to base 64.
// Token: 0x02000539 RID: 1337
[ComVisible(true)]
public class ToBase64Transform : IDisposable, ICryptoTransform
{
/// Releases the unmanaged resources used by the .
// Token: 0x060030FD RID: 12541 RVA: 0x000A843C File Offset: 0x000A663C
void IDisposable.Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
/// Releases the unmanaged resources used by the .
// Token: 0x060030FE RID: 12542 RVA: 0x000A844C File Offset: 0x000A664C
~ToBase64Transform()
{
this.Dispose(false);
}
/// Gets a value that indicates whether multiple blocks can be transformed.
/// Always false.
// Token: 0x17000998 RID: 2456
// (get) Token: 0x060030FF RID: 12543 RVA: 0x000A8488 File Offset: 0x000A6688
public bool CanTransformMultipleBlocks
{
get
{
return false;
}
}
/// Gets a value indicating whether the current transform can be reused.
/// Always true.
// Token: 0x17000999 RID: 2457
// (get) Token: 0x06003100 RID: 12544 RVA: 0x000A848C File Offset: 0x000A668C
public virtual bool CanReuseTransform
{
get
{
return true;
}
}
/// Gets the input block size.
/// The size of the input data blocks in bytes.
// Token: 0x1700099A RID: 2458
// (get) Token: 0x06003101 RID: 12545 RVA: 0x000A8490 File Offset: 0x000A6690
public int InputBlockSize
{
get
{
return 3;
}
}
/// Gets the output block size.
/// The size of the output data blocks in bytes.
// Token: 0x1700099B RID: 2459
// (get) Token: 0x06003102 RID: 12546 RVA: 0x000A8494 File Offset: 0x000A6694
public int OutputBlockSize
{
get
{
return 4;
}
}
/// Releases all resources used by the .
// Token: 0x06003103 RID: 12547 RVA: 0x000A8498 File Offset: 0x000A6698
public void Clear()
{
this.Dispose(true);
}
/// Releases the unmanaged resources used by the and optionally releases the managed resources.
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
// Token: 0x06003104 RID: 12548 RVA: 0x000A84A4 File Offset: 0x000A66A4
protected virtual void Dispose(bool disposing)
{
if (!this.m_disposed)
{
if (disposing)
{
}
this.m_disposed = true;
}
}
/// Converts the specified region of the input byte array to base 64 and copies the result to the specified region of the output byte array.
/// The number of bytes written.
/// The input to compute to base 64.
/// The offset into the input byte array from which to begin using data.
/// The number of bytes in the input byte array to use as data.
/// The output to which to write the result.
/// The offset into the output byte array from which to begin writing data.
/// The current object has already been disposed.
/// The data size is not valid.
/// The parameter contains an invalid offset length.-or-The parameter contains an invalid value.
/// The parameter is null.
/// The parameter requires a non-negative number.
// Token: 0x06003105 RID: 12549 RVA: 0x000A84C0 File Offset: 0x000A66C0
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
{
if (this.m_disposed)
{
throw new ObjectDisposedException("TransformBlock");
}
if (inputBuffer == null)
{
throw new ArgumentNullException("inputBuffer");
}
if (outputBuffer == null)
{
throw new ArgumentNullException("outputBuffer");
}
if (inputCount < 0)
{
throw new ArgumentException("inputCount", "< 0");
}
if (inputCount > inputBuffer.Length)
{
throw new ArgumentException("inputCount", Locale.GetText("Overflow"));
}
if (inputOffset < 0)
{
throw new ArgumentOutOfRangeException("inputOffset", "< 0");
}
if (inputOffset > inputBuffer.Length - inputCount)
{
throw new ArgumentException("inputOffset", Locale.GetText("Overflow"));
}
if (outputOffset < 0)
{
throw new ArgumentOutOfRangeException("outputOffset", "< 0");
}
if (outputOffset > outputBuffer.Length - inputCount)
{
throw new ArgumentException("outputOffset", Locale.GetText("Overflow"));
}
ToBase64Transform.InternalTransformBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
return this.OutputBlockSize;
}
// Token: 0x06003106 RID: 12550 RVA: 0x000A85C0 File Offset: 0x000A67C0
internal static void InternalTransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
{
byte[] encodeTable = Base64Constants.EncodeTable;
int num = (int)inputBuffer[inputOffset];
int num2 = (int)inputBuffer[inputOffset + 1];
int num3 = (int)inputBuffer[inputOffset + 2];
outputBuffer[outputOffset] = encodeTable[num >> 2];
outputBuffer[outputOffset + 1] = encodeTable[((num << 4) & 48) | (num2 >> 4)];
outputBuffer[outputOffset + 2] = encodeTable[((num2 << 2) & 60) | (num3 >> 6)];
outputBuffer[outputOffset + 3] = encodeTable[num3 & 63];
}
/// Converts the specified region of the specified byte array to base 64.
/// The computed base 64 conversion.
/// The input to convert to base 64.
/// The offset into the byte array from which to begin using data.
/// The number of bytes in the byte array to use as data.
/// The current object has already been disposed.
/// The parameter contains an invalid offset length.-or-The parameter contains an invalid value.
/// The parameter is null.
/// The parameter requires a non-negative number.
// Token: 0x06003107 RID: 12551 RVA: 0x000A861C File Offset: 0x000A681C
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{
if (this.m_disposed)
{
throw new ObjectDisposedException("TransformFinalBlock");
}
if (inputBuffer == null)
{
throw new ArgumentNullException("inputBuffer");
}
if (inputCount < 0)
{
throw new ArgumentException("inputCount", "< 0");
}
if (inputOffset > inputBuffer.Length - inputCount)
{
throw new ArgumentException("inputCount", Locale.GetText("Overflow"));
}
if (inputCount > this.InputBlockSize)
{
throw new ArgumentOutOfRangeException(Locale.GetText("Invalid input length"));
}
return ToBase64Transform.InternalTransformFinalBlock(inputBuffer, inputOffset, inputCount);
}
// Token: 0x06003108 RID: 12552 RVA: 0x000A86AC File Offset: 0x000A68AC
internal static byte[] InternalTransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{
int num = 3;
int num2 = 4;
int num3 = inputCount / num;
int num4 = inputCount % num;
byte[] array = new byte[(inputCount == 0) ? 0 : ((inputCount + 2) / num * num2)];
int num5 = 0;
for (int i = 0; i < num3; i++)
{
ToBase64Transform.InternalTransformBlock(inputBuffer, inputOffset, num, array, num5);
inputOffset += num;
num5 += num2;
}
byte[] encodeTable = Base64Constants.EncodeTable;
switch (num4)
{
case 1:
{
int num6 = (int)inputBuffer[inputOffset];
array[num5] = encodeTable[num6 >> 2];
array[num5 + 1] = encodeTable[(num6 << 4) & 48];
array[num5 + 2] = 61;
array[num5 + 3] = 61;
break;
}
case 2:
{
int num6 = (int)inputBuffer[inputOffset];
int num7 = (int)inputBuffer[inputOffset + 1];
array[num5] = encodeTable[num6 >> 2];
array[num5 + 1] = encodeTable[((num6 << 4) & 48) | (num7 >> 4)];
array[num5 + 2] = encodeTable[(num7 << 2) & 60];
array[num5 + 3] = 61;
break;
}
}
return array;
}
// Token: 0x04001403 RID: 5123
private const int inputBlockSize = 3;
// Token: 0x04001404 RID: 5124
private const int outputBlockSize = 4;
// Token: 0x04001405 RID: 5125
private bool m_disposed;
}
}