コード例 #1
0
        /// <summary>
        /// Encapsulates the specified links into an RSDF container.
        /// </summary>
        /// <param name="links">The links.</param>
        /// <returns>
        /// Base-16-encoded RSDF container.
        /// </returns>
        public static string CreateRSDF(string[] links)
        {
            var aes = new AesEngine();
            var cfb = new CfbBlockCipher(aes, 8);
            var pad = new BufferedBlockCipher(cfb);
            var sb  = new StringBuilder();

            pad.Init(true, new ParametersWithIV(new KeyParameter(RSDFKey), RSDFIV));

            foreach (var link in links)
            {
                var input  = Encoding.UTF8.GetBytes(link);
                var output = new byte[input.Length];

                for (var i = 0; i < input.Length; i++)
                {
                    output[i] = pad.ProcessByte(input[i])[0];
                }

                sb.Append(Convert.ToBase64String(output));
                sb.Append(Environment.NewLine);
            }

            return(BitConverter.ToString(Encoding.ASCII.GetBytes(sb.ToString())).Replace("-", string.Empty));
        }
コード例 #2
0
 public byte Decrypt(byte input)
 {
     if (!_enable)
     {
         throw new InvalidOperationException("加密未开启。");
     }
     return(_decrypt.ProcessByte(input)[0]);
 }
コード例 #3
0
        public int ReadByte()
        {
            var value = _baseStream.ReadByte();

            return(value == -1 ? value : _decryptCipher.ProcessByte((byte)value)[0]);
        }