H
http://sterlingdeepwaterbay.ath.cx
I am working on excryption for software my company si developing. Its
fairly simple. I use Rijndael Algorith , we could use DES or MD5.
Do you think that this way in secure enough.
Key is stored in the program. No way for any users to know it without
decompiling the prog.
login.db -> encrypted to log.enc
when an operation needs the db
decrypt(log.enc, key) ->login.db
perform operation
encrypt(login.db, key) -> log.enc
there will be some time elapsed where the db is vulnerable. But I
dont see a way around that unless we use a text file instead which
will complicate things.
Encyption
using System;
using System.IO;
using System.Text;
using System.Security.Cryptography;
namespace Encrypt
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Encrypt
{
[STAThread]
static void Main(string[] args)
{
UnicodeEncoding ue = new UnicodeEncoding();
byte[] key = ue.GetBytes("ehrtr43l");
FileStream fs = new FileStream("login.enc", FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fs,
RMCrypto.CreateEncryptor(key, key), CryptoStreamMode.Write);
Console.WriteLine("Encrypting " + args[0] + " ...");
FileStream fsIn=new FileStream(args[0],FileMode.Open);
int data;
while ((data=fsIn.ReadByte())!=-1)
cs.WriteByte((byte) data);
}
}
}
Decryption
using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;
namespace Decrypt
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Decrypt
{
[STAThread]
static void Main(string[] args)
{
UnicodeEncoding ue = new UnicodeEncoding();
byte[] key = ue.GetBytes("ehrtr43l");
FileStream fsIn = new FileStream("login.enc", FileMode.Open);
FileStream fsOut = new FileStream("out.txt", FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsOut,
RMCrypto.CreateDecryptor(key, key), CryptoStreamMode.Write);
Console.WriteLine("Decrypting login.enc ...");
int data;
while ((data=fsIn.ReadByte())!=-1)
cs.WriteByte((byte) data);
}
}
}
fairly simple. I use Rijndael Algorith , we could use DES or MD5.
Do you think that this way in secure enough.
Key is stored in the program. No way for any users to know it without
decompiling the prog.
login.db -> encrypted to log.enc
when an operation needs the db
decrypt(log.enc, key) ->login.db
perform operation
encrypt(login.db, key) -> log.enc
there will be some time elapsed where the db is vulnerable. But I
dont see a way around that unless we use a text file instead which
will complicate things.
Encyption
using System;
using System.IO;
using System.Text;
using System.Security.Cryptography;
namespace Encrypt
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Encrypt
{
[STAThread]
static void Main(string[] args)
{
UnicodeEncoding ue = new UnicodeEncoding();
byte[] key = ue.GetBytes("ehrtr43l");
FileStream fs = new FileStream("login.enc", FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fs,
RMCrypto.CreateEncryptor(key, key), CryptoStreamMode.Write);
Console.WriteLine("Encrypting " + args[0] + " ...");
FileStream fsIn=new FileStream(args[0],FileMode.Open);
int data;
while ((data=fsIn.ReadByte())!=-1)
cs.WriteByte((byte) data);
}
}
}
Decryption
using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;
namespace Decrypt
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Decrypt
{
[STAThread]
static void Main(string[] args)
{
UnicodeEncoding ue = new UnicodeEncoding();
byte[] key = ue.GetBytes("ehrtr43l");
FileStream fsIn = new FileStream("login.enc", FileMode.Open);
FileStream fsOut = new FileStream("out.txt", FileMode.Create);
RijndaelManaged RMCrypto = new RijndaelManaged();
CryptoStream cs = new CryptoStream(fsOut,
RMCrypto.CreateDecryptor(key, key), CryptoStreamMode.Write);
Console.WriteLine("Decrypting login.enc ...");
int data;
while ((data=fsIn.ReadByte())!=-1)
cs.WriteByte((byte) data);
}
}
}