コード例 #1
0
 /// <summary>
 /// 对文件主体部分进行加密
 /// </summary>
 /// <param name="date">数据</param>
 /// <param name="sendDateLabel">标签</param>
 /// <returns>加密之后的数据</returns>
 private static byte[] SendSubjectEncryption(byte[] date, int sendDateLabel)
 {
     byte[] dateOverall = ByteToDate.OffsetEncryption(date, sendDateLabel, 2);
     dateOverall[0] = PasswordCode._bigDateCode;
     dateOverall[1] = PasswordCode._fileSubjectCode;
     return(dateOverall);
 }
コード例 #2
0
        /// <summary>
        /// 对文件主体进行加密
        /// </summary>
        /// <param name="fileSend">FileState</param>
        /// <param name="bufferSize">缓冲区大小</param>
        /// <returns>加密之后数据</returns>
        internal static byte[] FileSubjectEncryption(FileState fileSend, int bufferSize)
        {
            byte[] dateOverall = null;
            if (fileSend.StateFile == 2)//说明我这里已经暂停了;要发一个暂停的消息给对方
            {
                dateOverall = FileSevenEncryption(PasswordCode._sendUser, PasswordCode._sendStop, fileSend.FileLabel);
                return(dateOverall);
            }
            int BufferSize = bufferSize - 24;

            if (fileSend.FileLenth - fileSend.FileOkLenth < BufferSize)
            {
                BufferSize = (int)(fileSend.FileLenth - fileSend.FileOkLenth);
            }
            byte[] haveDate      = new byte[BufferSize];
            int    haveDatelenth = 1;

            try
            {
                haveDatelenth = fileSend.Filestream.Read(haveDate, 0, BufferSize);
            }//异常说明这个文件已经被我方取消掉;返回一个取消信息给对方
            catch { return(EncryptionDecryptFile.FileSevenEncryption(PasswordCode._sendUser, PasswordCode._fileCancel, fileSend.FileLabel)); }
            if (haveDatelenth <= 0)
            {
                return(null); //说明数据发完了,文件会到外面去关掉
            }
            fileSend.FileOkLenth = fileSend.FileOkLenth + haveDatelenth;
            dateOverall          = ByteToDate.OffsetEncryption(haveDate, fileSend.FileLabel, 3);
            dateOverall[0]       = PasswordCode._fileCode;
            dateOverall[1]       = PasswordCode._sendUser;
            dateOverall[2]       = PasswordCode._fileSubjectCode;
            return(dateOverall);
        }
コード例 #3
0
 /// <summary>
 /// 一个普通的对数据主体部分进行加密;
 /// </summary>
 /// <param name="date">要加密的数据</param>
 /// <param name="textCode"></param>
 /// <param name="state">StateBase</param>
 /// <returns>加密之后的数据</returns>
 private static byte[] encryptionTemporary(byte[] date, byte textCode, StateBase state)
 {
     if (date.Length > state.BufferSize - 20)
     {
         return(EncryptionDecryptSeparateDate.SendHeadEncryption(date, textCode, state)); //超出通过文件系统发送
     }
     state.SendDateLabel = RandomPublic.RandomNumber(16787);                              //给发送的数据进行编号
     byte[] dateOverall = ByteToDate.OffsetEncryption(date, state.SendDateLabel, 2);
     dateOverall[0] = PasswordCode._commonCode; dateOverall[1] = textCode;
     return(dateOverall);
 }