|
My plaintex is a four digit xters, after encryption i get a 24 digit set of xters,
i want to limit the encrypted values to just 10 digits,
is that posible?
if so pls how?
thank you.
|
|
|
|
|
Looking briefly at your code reply on the other thread, this is for password matching?
If so, then just do what everyone else does - don't use encryption, use hashing. MD5 or SHA will give you a 128bit hash of a password which you can store and check against. That is what most do - since it is a hash, it is not reversible (you don't need a key to generate it, just the password) and it can't be reverse engineered to get the password (particularly for SHA, MD5 can be revwerse engineeered in some circumstances).
It is also a good idea to include the UserId with the password before hashing, so that two users with the same password don't generate the same hash...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
What method of encryption are you using that is resulting the the 24 character result?
What factors made you choose this method of encryption?
Why are you encypting the value?
Do you need to be able to decrypt the result in order to obtain the original value?
Are there any transport considerations e.g. 7-bit transmission restriction?
Need more info to help.
|
|
|
|
|
What code you have written?
If it is showing any error then put your error we will help you.
Regards,
Sathesh.
The best way to express one's gratitude to the Divine is to feel simply Happy..
|
|
|
|
|
here is my code:
public static string iEncrypt(string plainText, string passPhrase, string saltValue,
string HashAlgorithm, int passwordIterations, string initVector,
int KeySizes)
{
byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, saltValueBytes, HashAlgorithm, passwordIterations);
byte[] keyBytes = password.GetBytes(KeySizes / 8);
RijndaelManaged symmetricaKey = new RijndaelManaged();
symmetricaKey.Mode = CipherMode.CBC;
ICryptoTransform encryptor = symmetricaKey.CreateEncryptor(keyBytes, initVectorBytes);
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write);
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
cryptoStream.FlushFinalBlock();
byte[] cipherTextBytes = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
string cipherText = Convert.ToBase64String(cipherTextBytes);
return cipherText;
}
static void Main(string[] args)
{
//string plainText="Hello World!";
string plainText;
string passPhrase = "Pas5pr@se";
//string passPhrase = "123456789";
//string saltValue = "123456789";//s@ltValue";
string saltValue = "s@ltValue";
string hashAlgorithm = "SHA1";
int passwordIterations = 1;
//string initVector = "abcdefghijklmnop";//@1B2c3D4e5F6g7H8";
string initVector = "@1B2c3D4e5F6g7H8";
int keySize = 64;//256;
//Console.WriteLine(string.Format("Plaintext : {0}", plainText));
Console.WriteLine(string.Format("Type Plaintext : "));
plainText= Console.ReadLine();
string cipherText = dEncrypt.iEncrypt(plainText, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
Console.WriteLine(string.Format("Encrypted : {0}", cipherText));
}
|
|
|
|
|
Please remember to use the pre tags when posting code snippets.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi All,
I want to have an ASP C# WebSite that loads a simple CSV File and present it in a GridView control (at least for a start).
I already have a piece of code that do almost all of the work, what i miss / unable to make it work is setting correctly the "Data Source".
The CSV file that I want to load is located on different server in the network (path is "\\td47vc\public\Joe\ASP\Test").
Here is the code I wrote:
public DataSet GetCSVFile(string fileName)
{
string pathName = "\\td47vc\\public\\Joe\\ASP\\Test";
string file = System.IO.Path.GetFileName(fileName);
OleDbConnection excelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + ";Extended Properties=Text;");
OleDbCommand excelCommand = new OleDbCommand(@"SELECT * FROM " + file, excelConnection);
OleDbDataAdapter excelAdapter = new OleDbDataAdapter(excelCommand);
excelConnection.Open();
DataSet ds = new DataSet();
excelAdapter.Fill(ds);
excelConnection.Close();
return ds;
}
I get the following error:
'\\td47vc\public\Joe\ASP\Test' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Thanks,
GorovDude
|
|
|
|
|
Well you could try:
0)
@"\\td47vc\public\Joe\ASP\Test";
1) Using the IP of the server instead of the server name (10.xx.xx.xx instead of \\someserver01).
Maybe it's on a different VLAN and it does not know it by name
2) If it still doesn't work then it's clearly a matter of credentials/rights. That one only you and/or the admin can fix.
I used to think....
Finally I realized it's no good.
modified on Tuesday, December 7, 2010 4:28 AM
|
|
|
|
|
do you really want double backslashes everywhere?
|
|
|
|
|
Nice.
I missed it completely. Just focused on the start. Fixed.
I used to think....
Finally I realized it's no good.
|
|
|
|
|
you'll have to try again I'm afraid, if you want a double backslash, either give four, or use '@'; three backslashes is no good.
I prefer the '@' approach, as that takes and shows the string as intended.
|
|
|
|
|
Yep that's what I did. Just before you fixed my "code" the second time
I guess I'm better of just fooling around.
I used to think....
Finally I realized it's no good.
|
|
|
|
|
looking great now.
|
|
|
|
|
See this[^].it might be helpful.
|
|
|
|
|
what about setting your connection string in web inf instead of code
|
|
|
|
|
|
Try mapping virtual path to physical path using Server object. For example where you are doing
string pathName = "\\td47vc\\public\\Joe\\ASP\\Test";
instead do it something like
string pathName = Server.MapPath("~/Joe/Asp/Test.csv");
Where you need to make sure you are passing correct virtual path to MapPath call. You need to specify it relative to your application root.
I Web Development Free Lancer
Share your experience with others
Check my Blog...
|
|
|
|
|
Hi friends & seniors,
i have a Vc++ dll in which i return a struct of LOGFONT menbers
<pre> struct xyzStruct
{
LOGFONT a;
}
extern "c" __dllspec ... xyzStruct a()
</pre>
this data is populated in vc++ dll and passed to a C# form
in the C# side i have created
<pre>[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class LOGFONT
{
public int lfHeight = 0;
public int lfWidth = 0;
public int lfEscapement = 0;
public int lfOrientation = 0;
public int lfWeight = 0;
public byte lfItalic = 0;
public byte lfUnderline = 0;
public byte lfStrikeOut = 0;
public byte lfCharSet = 0;
public byte lfOutPrecision = 0;
public byte lfClipPrecision = 0;
public byte lfQuality = 0;
public byte lfPitchAndFamily = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string lfFaceName = string.Empty;
}
</pre>
then i make pinvoke to the DLL
<pre>
[StructLayout(LayoutKind.Sequential)]
public class xyzStruct
{
public lOGFONT a;
}
[dllImport ("Dll name")]
public static extern xyzStruct a();
</pre>
i get error "methods signature is not pinvoke comaptible"
i try using int in struct in both dll and form everything works fine.
thanks in advance
Regards
Samir
|
|
|
|
|
Make your method in the C++ library return a pointer to a LOGFONT instead, import the method in C# with IntPtr as return type and use Marshal.PtrToStructure to get the structure in C#.
|
|
|
|
|
Please Reformat your code to make it readability use Code-Block to Wrap your code.
|
|
|
|
|
hi
i make from my program an excel file (xls or csv)
i send `00123` and in the excel i see `123`
how i can send and see `00123`
thank's in advance
|
|
|
|
|
excel is treating (rightly) that data as a numeric, you need to tell excel it is a string by enclosing it in "" or prefixing it with a single quote ' (I think)
Or better yet change the display format of the cell in excel to pad with preceding zeros.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How to send sms from asp.net without gateway, is it possible?, if so how?
|
|
|
|
|
|
I believe you will be required to have your custom SMS server type thing. For example some custom piece of software running on some septate machine that could pick alerts from your online database after certain intervals and the flush them out in SMS form.
BTW you can also do another trick and that is if your mobile service providers support Email message using mobile phone number then you can simply trigger an Email with mobile number as to address while message content in subject of Email. This Email will be delivered as SMS.
I Web Development Free Lancer
Share your experience with others
Check my Blog...
|
|
|
|