Ejemplo n.º 1
0
 public static byte[] Sha256(byte[] clientKey)
 {
     using( var sha = new IncrementalSHA256() )
     {
         sha.AppendData(clientKey);
         return sha.GetHashAndReset();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an UploadStream to ReGrid.
        /// </summary>
        /// <param name="conn">RethinkDB Connection or ConnectonPool.</param>
        /// <param name="filesInfoId">The ID of the FileInfo in the database.</param>
        /// <param name="fileInfo">An incomplete FileInfo that exists in the database waiting to be finalized.</param>
        /// <param name="fileTable">An already namespaced Table term for FileInfo.</param>
        /// <param name="chunkTable">An already namespaced Table term for Chunk</param>
        /// <param name="options">Upload options</param>
        internal UploadStream(IConnection conn, Guid filesInfoId, FileInfo fileInfo, Table fileTable, Table chunkTable, UploadOptions options) : base(fileInfo)
        {
            this.conn            = conn;
            this.filesInfoId     = filesInfoId;
            this.fileTable       = fileTable;
            this.chunkTable      = chunkTable;
            this.chunkInsertOpts = options.ChunkInsertOptions;
            this.chunkSizeBytes  = options.ChunkSizeBytes;

            this.batchSize = options.BatchSize;

            this.batch = new List <byte[]>();

            sha256 = new IncrementalSHA256();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an UploadStream to ReGrid.
        /// </summary>
        /// <param name="conn">RethinkDB Connection or ConnectonPool.</param>
        /// <param name="filesInfoId">The ID of the FileInfo in the database.</param>
        /// <param name="fileInfo">An incomplete FileInfo that exists in the database waiting to be finalized.</param>
        /// <param name="fileTable">An already namespaced Table term for FileInfo.</param>
        /// <param name="chunkTable">An already namespaced Table term for Chunk</param>
        /// <param name="options">Upload options</param>
        internal UploadStream(IConnection conn, Guid filesInfoId, FileInfo fileInfo, Table fileTable, Table chunkTable, UploadOptions options) : base(fileInfo)
        {
            this.conn = conn;
            this.filesInfoId = filesInfoId;
            this.fileTable = fileTable;
            this.chunkTable = chunkTable;
            this.chunkInsertOpts = options.ChunkInsertOptions;
            this.chunkSizeBytes = options.ChunkSizeBytes;

            this.batchSize = options.BatchSize;

            this.batch = new List<byte[]>();

            sha256 = new IncrementalSHA256();
        }
        public DownloadStreamForwardOnly(Bucket bucket, FileInfo fileInfo, DownloadOptions options)
            : base(bucket, fileInfo)
        {
            if( options.CheckSHA256 )
            {
                this.sha256 = new IncrementalSHA256();
                this.checkSHA256 = true;
            }

            lastChunkNumber = (int)((fileInfo.Length - 1) / fileInfo.ChunkSizeBytes);
            lastChunkSize = (int)(fileInfo.Length % fileInfo.ChunkSizeBytes);

            if( lastChunkSize == 0 )
            {
                lastChunkSize = fileInfo.ChunkSizeBytes;
            }
        }
        public DownloadStreamForwardOnly(Bucket bucket, FileInfo fileInfo, DownloadOptions options)
            : base(bucket, fileInfo)
        {
            if (options.CheckSHA256)
            {
                this.sha256      = new IncrementalSHA256();
                this.checkSHA256 = true;
            }

            lastChunkNumber = (int)((fileInfo.Length - 1) / fileInfo.ChunkSizeBytes);
            lastChunkSize   = (int)(fileInfo.Length % fileInfo.ChunkSizeBytes);

            if (lastChunkSize == 0)
            {
                lastChunkSize = fileInfo.ChunkSizeBytes;
            }
        }