コード例 #1
0
        /// <summary>
        /// Try get algorithm from mechanism.
        /// </summary>
        /// <param name="mechanism">Algorithm mechanism.</param>
        /// <param name="algorithm">Algorithm.</param>
        /// <returns></returns>
        public static bool TryGetAlgorithm(string mechanism, out IStreamAlgorithm algorithm)
        {
            mechanism = mechanism.Replace('_', '-').Replace('/', '-').ToUpperInvariant();
            switch (mechanism)
            {
            case "CHACHA": algorithm = ChaCha; return(true);

            case "CHACHA7539":
            case "CHACHA20": algorithm = ChaCha7539; return(true);

            case "HC128":
            case "HC-128": algorithm = HC128; return(true);

            case "HC256":
            case "HC-256": algorithm = HC256; return(true);

            case "ISAAC": algorithm = ISAAC; return(true);

            case "RC4":
            case "ARC4":
            case "ARCFOUR": algorithm = RC4; return(true);

            case "SALSA20": algorithm = Salsa20; return(true);

            case "VMPC": algorithm = VMPC; return(true);

            case "VMPC-KSA3":
            case "VMPCKSA3": algorithm = VMPC_KSA3; return(true);

            case "XSALSA20": algorithm = XSalsa20; return(true);

            default: algorithm = null; return(false);
            }
        }
コード例 #2
0
 public StreamUnit(StreamAlgorithm algorithm)
 {
     _algorithm = StreamAlgorithmFactory.CreateAlgorithm(algorithm);
     _stats     = new StreamStats(algorithm);
     Busy       = false;
 }