Argentini.Halide.H3Secure.EncryptInt64 C# (CSharp) Method

EncryptInt64() public static method

Triple DES 256 bit encryption of 64-bit integers.
public static EncryptInt64 ( System.Int64 data, Byte key, Byte ivec ) : String
data System.Int64 Long integer to encrypt.
key Byte 24 byte array key for encrypting the data.
ivec Byte 18 byte array initialization vector for the encryption routine.
return String
        public static String EncryptInt64(Int64 data, Byte[] key, Byte[] ivec)
        {
            String retVal = "";

            try
            {
                ASCIIEncoding encoder = new ASCIIEncoding();

                Byte[] inputInBytes = BitConverter.GetBytes(data);

                AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider();
                aesProvider.BlockSize = 128;
                aesProvider.KeySize = 256;
                ICryptoTransform cryptoTransform = aesProvider.CreateEncryptor(key, ivec);
                MemoryStream encryptedStream = new MemoryStream();
                CryptoStream cryptStream = new CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write);

                cryptStream.Write(inputInBytes, 0, inputInBytes.Length);
                cryptStream.FlushFinalBlock();
                encryptedStream.Position = 0;

                Byte[] result = new byte[encryptedStream.Length];
                encryptedStream.Read(result, 0, Convert.ToInt32(encryptedStream.Length));

                cryptStream.Close();

                retVal = Base64PlusStringEncode(result);
            }

            catch (Exception err)
            {
                throw new Exception("Halide.H3Secure Error: " + err.ToString());
            }

            return retVal;
        }

Same methods

H3Secure::EncryptInt64 ( System.Int64 data ) : String
H3Secure::EncryptInt64 ( System.Int64 data, Byte key ) : String
H3Secure::EncryptInt64 ( System.Int64 data, String key, String ivec ) : String