Beispiel #1
0
        /// ****************************************************************************
        /// Encryption and Decryption Algorithms
        /// ****************************************************************************

        public byte[] Encrypt_Serpent(string plainMessage)
        {
            CipherKeyGenerator cipherKeyGenerator = new CipherKeyGenerator();

            cipherKeyGenerator.Init(new KeyGenerationParameters(new SecureRandom(), 128));
            byte[]  key          = cipherKeyGenerator.GenerateKey();
            byte [] iv           = cipherKeyGenerator.GenerateKey();
            byte[]  encrptedDAta = SerpentAlgo.SerpentEncryption(plainMessage, key);
            return(encrptedDAta.Concat(key).Concat(iv).ToArray());
        }
Beispiel #2
0
        public void SerpentTest()
        {
            CipherKeyGenerator cipherKeyGenerator = new CipherKeyGenerator();

            cipherKeyGenerator.Init(new KeyGenerationParameters(new SecureRandom(), 128));
            byte[] key     = cipherKeyGenerator.GenerateKey();
            string message = "Hello World!";

            // Encrypt the string to an in-memory buffer.

            byte[] encrptedDAta = SerpentAlgo.SerpentEncryption(message, key);

            // Decrypt the buffer back to a string.
            string plainText = SerpentAlgo.SerpentDecryption(encrptedDAta, key);

            // Display the decrypted string to the console.

            Console.WriteLine(plainText);
        }
Beispiel #3
0
        public string Decrypt_Serpent(byte[] cypherData, byte[] key)
        {
            string plainText = SerpentAlgo.SerpentDecryption(cypherData, key);

            return(plainText);
        }