示例#1
0
        static void DES_BLOCK_TEST()
        {
            string strPlain =
                "C#[b] (/si: ʃɑːrp/) is a multi-paradigm programming language " +
                "encompassing strong typing, imperative, declarative, functional," +
                " generic, object-oriented (class-based), and component-oriented " +
                "programming disciplines. It was developed around 2000 by Micros" +
                "oft within its .NET initiative and later approved as a standard" +
                " by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of " +
                "the programming languages designed for the Common Language Infr" +
                "astructure.C# is a general-purpose, object-oriented programming " +
                "language. Its development team is led by Anders Hejlsberg. The m" +
                "ost recent version is C# 7.3, which was released in 2018 alongsi" +
                "de Visual Studio 2017 version 15.7.2.";

            byte[] baPlain = Encoding.Unicode.GetBytes(strPlain);
            ulong  key     = 0x0123456789ABCDEF;

            DES_lib.Mode[] modes = new DES_lib.Mode[] { DES_lib.Mode.ECB, DES_lib.Mode.CBC, DES_lib.Mode.CFB, DES_lib.Mode.OFB, DES_lib.Mode.PCBC };
            foreach (DES_lib.Mode m in modes)
            {
                byte[] baCipher = DES_Main.EncryptBlockB(baPlain, key, key, m);
                byte[] baResult = DES_Main.DecryptBlockB(baCipher, key, key, m);
                Console.WriteLine(Encoding.Unicode.GetChars(baResult));
                Console.WriteLine("**************************************************");
            }
        }
示例#2
0
 public byte[] DES_Crypt(bool action, byte[] baData, ulong ulKey, ulong ulIV, int mode)
 {
     if (action)
     {
         return(DES_Main.DecryptBlockB(baData, ulKey, ulIV, (DES_lib.Mode)mode));
     }
     else
     {
         return(DES_Main.EncryptBlockB(baData, ulKey, ulIV, (DES_lib.Mode)mode));
     }
 }