Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
3

3bood ghzawi

@3bood ghzawi
About
Posts
47
Topics
40
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Ad Hoc routing protocol
    3 3bood ghzawi

    All these search results are papers, but i need a written code

    Managed C++/CLI help question

  • Ad Hoc routing protocol
    3 3bood ghzawi

    Thanks alot, but i need a simulation for any BTMA, DBTMA or DUCHA . i've a similar project based on multi-channel and busy tones. regards

    Managed C++/CLI help question

  • Ad Hoc routing protocol
    3 3bood ghzawi

    can anyone help me finding the source code or the simulation of the Dual Busy Tone Multiple Access (DBTMA) protocol ???? regards... :^) :~ :wtf:

    Managed C++/CLI help question

  • INVALID_HANDLE_VALUE
    3 3bood ghzawi

    hi all, i've aproblem with this function, i hope you don't minde to help me CreateFileA(m_pstrAllUsersPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 128, NULL); the m_pstrAllUsersPath value is "C:\Documents and Settings\All Users\Application Data\Avg9\update\download\avginfoavi.ctf". It always return INVALID_HANDLE_VALUE although this file exist. regards

    C / C++ / MFC help announcement

  • how to create a website page ???
    3 3bood ghzawi

    Hi all, i new at asp.net and need to create a website page using asp.net , but i don't know how<<<<<<<<<<<<<< regards...

    ASP.NET csharp asp-net tutorial question

  • Decrypting a text using Rijndael
    3 3bood ghzawi

    Hi all, i have been using a Rijndael algorithm to encrypt and decrypt a sequence of bytes, but when i run the code i get the following exeption "Padding is invalid and cannot be removed.", this exeption belongs to decrypt function at line int decryptedByteCount = cryptoStream.Read(pTextBytes, 0, pTextBytes.Length); i writ my code here:

    public static byte[] Encrypt(byte[] clearData)
    {
    System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
    //Get your key from config file to open the lock!
    string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

            MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
            byte\[\] keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            hashmd5.Clear();
    
            Rijndael rijKey = Rijndael.Create();
            rijKey.Mode = CipherMode.ECB;
            rijKey.Padding = PaddingMode.PKCS7;
            MemoryStream ms = new MemoryStream();
            CryptoStream cs = new CryptoStream(ms,rijKey.CreateEncryptor(), CryptoStreamMode.Write); 
            cs.Write(clearData, 0, clearData.Length);
            cs.FlushFinalBlock();
            byte\[\] cipherTextBytes = ms.ToArray();
            ms.Close();
            cs.Close();
    
            return cipherTextBytes;
        }
    
        public static byte\[\] Decrypt(byte\[\] encryptedData)
        {
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            //Get your key from config file to open the lock!
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
            byte\[\] keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            hashmd5.Clear();
    
            Rijndael rijKey = Rijndael.Create();
            rijKey.Mode = CipherMode.ECB;
            rijKey.Padding = PaddingMode.PKCS7;
            MemoryStream memoryStream = new MemoryStream(encryptedData);
            CryptoStream cryptoStream = new CryptoStream(memoryStream, rijKey.CreateDecryptor(),
            CryptoStreamMode.Read);
            byte\[\] pTextBytes = new byte\[encryptedData.Length\];
            int decryptedByteCount = cryptoStream.Read(pTextBytes, 0, pTextBytes.Length);
            memoryStream.Close();
            cryptoStream.Close();
            return pTextBytes;
        }
    
    C# algorithms workspace

  • Decrypting a text using Rijndael
    3 3bood ghzawi

    Hi all, i have been using a Rijndael algorithm to encrypt and decrypt a sequence of bytes, but when i run the code i get the following exeption "Padding is invalid and cannot be removed.", this exeption belongs to decrypt function at line int decryptedByteCount = cryptoStream.Read(pTextBytes, 0, pTextBytes.Length); i writ my code here:

    public static byte[] Encrypt(byte[] clearData)
    {
    System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
    //Get your key from config file to open the lock!
    string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

            MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
            byte\[\] keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            hashmd5.Clear();
    
            Rijndael rijKey = Rijndael.Create();
            rijKey.Mode = CipherMode.;
            rijKey.Padding = PaddingMode.PKCS7;
            MemoryStream ms = new MemoryStream();
            CryptoStream cs = new CryptoStream(ms,rijKey.CreateEncryptor(), CryptoStreamMode.Write); 
            cs.Write(clearData, 0, clearData.Length);
            cs.FlushFinalBlock();
            byte\[\] cipherTextBytes = ms.ToArray();
            ms.Close();
            cs.Close();
    
            return cipherTextBytes;
        }
    
        public static byte\[\] Decrypt(byte\[\] encryptedData)
        {
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            //Get your key from config file to open the lock!
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
            byte\[\] keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            hashmd5.Clear();
    
            Rijndael rijKey = Rijndael.Create();
            rijKey.Mode = CipherMode.ECB;
            rijKey.Padding = PaddingMode.PKCS7;
            MemoryStream memoryStream = new MemoryStream(encryptedData);
            CryptoStream cryptoStream = new CryptoStream(memoryStream, rijKey.CreateDecryptor(),
            CryptoStreamMode.Read);
            byte\[\] pTextBytes = new byte\[encryptedData.Length\];
            int decryptedByteCount = cryptoStream.Read(pTextBytes, 0, pTextBytes.Length);
            memoryStream.Close();
            cryptoStream.Close();
            return pTextBytes;
        }
    
    C# algorithms workspace

  • what that means
    3 3bood ghzawi

    Hi all, i need helping about if (pcap_addr.Addr != IntPtr.Zero)</ is that mean (at C++): if (pcap_addr.Addr != null)

    C# c++

  • what this means
    3 3bood ghzawi

    Hi all, i read that but don't understand it, can you illustrate it to me, pleae,,.

    [SuppressUnmanagedCodeSecurityAttribute]

    // Allows managed code to call into unmanaged code without a stack walk. // 1- This attribute can be applied to methods that want to call into native // code without incurring the performance loss of a run-time security check when doing so. // 2- Using this attribute in a class applies it to all contained methods. regards..,

    C# c++ data-structures security performance

  • encryption & decryption
    3 3bood ghzawi

    hi all, i use the following algorithms to encrypt then to decrypt a sequence of bytes, but the decryption algorithm always return an exception <Length of the data to decrypt is invalid< i don't know why that, both algorithms are below..,

    public class CryptorEngine
    {
    static public byte[] keyArray;
    static public byte[] resultArray;

        public static void Encrypt(byte\[\] toEncryptArray, bool useHashing)
        {
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            // Get the key from config file
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                CryptorEngine.keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                CryptorEngine.keyArray = UTF8Encoding.UTF8.GetBytes(key);
    
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;
    
            ICryptoTransform cTransform = tdes.CreateEncryptor();
            CryptorEngine.resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();
        }
    }
    

    ////////////////////////////////////////////////////////////////////////////

    public class DecryptorEngine
    {
        static public byte\[\] keyArray;
        static public byte\[\] resultArray;
        
        public static void Decrypt(byte\[\] toEncryptArray, bool useHashing)
        {
           System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            //Get your key from config file to open the lock!
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
    
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                DecryptorEngine.keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                DecryptorEngine.keyArray = UTF8Encoding.UTF8.GetBytes(key);
    
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes
    
    C# algorithms security workspace

  • Decryption algorithm
    3 3bood ghzawi

    very thanks stancrm, but sorry, i really new at C# and don't understand that........ can you make it more esey ...; thanks.., :-D

    C# algorithms data-structures help workspace

  • Decryption algorithm
    3 3bood ghzawi

    Hi all, as runing this algorithm, that decrypt an encrypted array of bytes, allways returns null as a decrypted result... the code is below:

    public static void Decrypt(byte[] toEncryptArray, bool useHashing)
    {
    System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
    //Get your key from config file to open the lock!
    string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                D\_keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                D\_keyArray = UTF8Encoding.UTF8.GetBytes(key);
    
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = D\_keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;
    
            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte\[\] D\_resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
           
             //  the D\_resultArray always get a null value
            tdes.Clear();
       }
    

    Can any one help me ,,,,,,,,, i'll be very thanks.., regards :-D

    C# algorithms data-structures help workspace

  • Encrytion and decryption a string [modified]
    3 3bood ghzawi

    Hello anyone.., How we can differentiate between an encrypted and none encrypted txt??? i need a method for that, to using in my project..., Please help me.........,,, An encryption methode is below:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Security.Cryptography;
    using System.Configuration;

    namespace SharpPcap.EnCryptDecrypt
    {
    public class CryptorEngine
    {
    public static string Encrypt(string toEncrypt, bool useHashing)
    {
    byte[] keyArray;
    byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            // Get the key from config file
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            //System.Windows.Forms.MessageBox.Show(key);
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                keyArray = UTF8Encoding.UTF8.GetBytes(key);
    
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;
    
            ICryptoTransform cTransform = tdes.CreateEncryptor();
            byte\[\] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();
            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }
    }
    

    }

    Regards...

    modified on Wednesday, January 27, 2010 6:56 AM

    C# security help question workspace

  • Marshalling
    3 3bood ghzawi

    Hi all, i asking about marshalling, what it is means, and why we need it??? I face this statment at some code, but i don't know exactly what it means ..; < // Marshal pointer into a struct PcapUnmanagedStructures.pcap_if pcap_if_unmanaged = (PcapUnmanagedStructures.pcap_if)Marshal.PtrToStructure(nextDevPtr, typeof(PcapUnmanagedStructures.pcap_if)); >

    C# question

  • Socket listening
    3 3bood ghzawi

    Hi all, i'm asking how to use a socket class to listening to all ports and reciving all packets... Regards

    C# tutorial

  • Managed and Unmanaged code
    3 3bood ghzawi

    Hi anyone, i asking about managed and unmanaged code and why we need that??? I need a good reference to know in depth about them........... Regards

    C# question

  • managed and unmanaged code............
    3 3bood ghzawi

    Hi all, pardon me, I need helping at the following code. When I run this code to get the IP address (at statement Console.WriteLine(ipAddress)) I get the IP address, subnet mask and network family at this maner: 169.254.25.129 255.255.0.0 255.255.255.255 but I need to get each of them uniqly (each one alone of others), and I need to get these using this code of the programe (this code from SharpPcap.2-1-1)…. Regards………………………….. public Sockaddr(IntPtr sockaddrPtr) { // A sockaddr struct. We use this to determine the address family PcapUnmanagedStructures.sockaddr saddr; // Marshal memory pointer into a struct saddr = (PcapUnmanagedStructures.sockaddr)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr)); // record the sa_family for informational purposes _sa_family = saddr.sa_family; byte[] addressBytes; if(saddr.sa_family == Pcap.AF_INET) { type = Type.AF_INET_AF_INET6; PcapUnmanagedStructures.sockaddr_in saddr_in = (PcapUnmanagedStructures.sockaddr_in)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr_in)); ipAddress = new System.Net.IPAddress(saddr_in.sin_addr.s_addr); Console.WriteLine(ipAddress); } }// end of Sockaddr function ///////////////////////////////////////////////////////////////////////////////// // A PcapUnmanagedStructures class is here: public class PcapUnmanagedStructures { #region Unmanaged Structs Implementation [StructLayout(LayoutKind.Sequential)] public struct sockaddr { public UInt16 sa_family; /* address family */ [MarshalAs(UnmanagedType.ByValArray, SizeConst=14)] public byte[] sa_data; /* 14 bytes of protocol address */ }; /// <summary> /// Structure that holds an ipv4 address /// </summary> public struct in_addr { public UInt32 s_addr/*= 1111*/; } /// <summary> /// Structure that holds an ipv4 address /// 'struct sockaddr' /// </summary> [StructLayout(LayoutKind.Sequential)] public struct sockaddr_in { public UInt16 sa_family; /* address

    C# csharp sysadmin performance

  • [StructLayout(LayoutKind.Sequential)]
    3 3bood ghzawi

    Hi all, i counter this statment at some code, but i don't undestand what means, so, i need helping of what it means in detail... [StructLayout(LayoutKind.Sequential)] Thanks......

    C#

  • Constructing a Secure Socket Layer header and IPSec header
    3 3bood ghzawi

    Hi all, i wondering of how i can build a SSL header (either using built in or built out function) using C#, and a same for IPSec.......... Thanks...

    C# csharp security

  • Checking if my gateway connected to internet (online) or not (offline)…
    3 3bood ghzawi

    Hi Matt Meyer i thank u for intersting, but i need that using coding ..........

    C# csharp question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups