[Message Deleted]
Roshanakak
Posts
-
[Message Deleted] -
Problem in Printing a persian(or arabic) documentHi, i need to print a document in my c# application, this document has some utf8 characters because it is in persian language (these characters also can be found in arabic), but when i use printdocument and printdialog components the printed page is full of nonsense characters, i think it must be about the language and i tried to google it but i couldn't find another component in net, can anybody please help me??? Roshanakak
-
I have problems in word automationHi, I'm doing some Microsoft Word automation using Microsoft.Office.Interop.Word namespace, in this application i'm opening a file (template.docx) and making some changes in it and then saving it. Just when the file is going to be opened:
myWordDoc = myWordApp.Documents.Add(ref filename, ref missing, ref missing, ref missing);
i receive this exception:Word was unable to read this document. It may be corrupt. Try one or more of the following: * Open and Repair the file. * Open the file with the Text Recovery converter.
but i'm sure the file is not corrupt, i can open it in word and its data is correct. Whould anyone please tell me what should i do now??? Thanks in Advance Roshanak -
I have a problem with Convert.FromBase64StringI'm trying to encrypt sth, and those lines were just a part of my code. I'm sorry for not being clear but i wanted to be brief, this is the whole code:
using System; using System.IO; using System.Text; using System.Security.Cryptography; namespace Cryptography { public sealed class Cryption { private RijndaelManaged Algorithm; private string m_key; private string m_iv; private byte[] key; private byte[] iv; public Cryption(string key_val, string iv_val) { key = new byte[32]; iv = new byte[32]; int i; m_key = key_val; m_iv = iv_val; for (i = 0; i < m_key.Length; i++) { key[i] = Convert.ToByte(m_key[i]); } for (i = 0; i < m_iv.Length; i++) { iv[i] = Convert.ToByte(m_iv[i]); } } public string Encrypt(string s) { string enc_str; byte[] enc_byte; Algorithm = new RijndaelManaged(); Algorithm.BlockSize = 256; Algorithm.KeySize = 256; Algorithm.Padding = PaddingMode.PKCS7; using (MemoryStream memStream = new MemoryStream()) { using (ICryptoTransform EncryptorDecryptor = Algorithm.CreateEncryptor(key, iv)) { using (CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Write)) { UTF8Encoding utf8enc = new UTF8Encoding(); enc_byte = utf8enc.GetBytes(s); crStream.Write(enc_byte, 0, enc_byte.Length); crStream.FlushFinalBlock(); } } } enc_str = Convert.ToBase64String(enc_byte); return enc_str; } public string Decrypt(string s) { string dec_str; //byte[] dec_byte; byte[] decrepted_byte; Algorithm = new RijndaelManaged(); Algorithm.BlockSize = 256; Algorithm.KeySize = 256; Algorithm.Padding = PaddingMode.PKCS7; byte[] dec_byte = new byte[s.Length]; dec_byte = Convert.FromBase64String(s); decrepted_byte = new byte[dec_byte.Length]; us
-
I have a problem with Convert.FromBase64StringI have this code in my project:
string str; byte[] enc = new byte[str.length]; enc = Convert.FromBase64String(str);
when i trace it, in the 2nd line the enc is a byte with the length of str but when 3rd line executes the enc length becomes 1 and therefore my data is not valid at the end. does anybody know what should i do? Roshanak -
About the certification validation periodwant to sign my project assembly files with some private key and i'm using x509certificate class. I need this certification to be valid permenently, what should i do? we don't have access to edit the validation period in the certification directly, right? any ideas????? Should i use another approach for my aim? What? I appreciate any ideas... Roshanak
-
i need help with a cryptography exception!I set the padding to pkcs7 in both encryption and decryption and i build the project again but it still makes the exception. About encoding format, i'm using unicodeEncoding in both, you can see in encryption:
pwd_str= new UnicodeEncoding().GetString(pwd_byte); return pwd_str;
and in decryption:MemoryStream memStream = new MemoryStream(new UnicodeEncoding().GetBytes(s));
and for the streams:strWriter.Flush(); crStream.FlushFinalBlock();
i don't know how else i can flush them!!! Again THANKS Roshanak -
I need some information on enabling-disabling a software (registration-activation)yes, i found it. now i have my own software, you mean if i install it (for example with windows installer) it creates this registry key for it's own and then i can do what i want??? or i must insert the creation of this key in my code???? Roshanak
-
I need some information on enabling-disabling a software (registration-activation)I have a project in C#. Now i have this problem: after installing this software it should be disabled and the user must register it in our website, then with an activation key that would be given in the website the software should be enabled again! I really know nothing about how it should be done. Would anybody please help me??? it's so urgent!!! Roshanak
-
i need help with a cryptography exception!here is the stack trace:
System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) at System.Security.Cryptography.CryptoStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.IO.StreamReader.ReadBuffer() at System.IO.StreamReader.ReadToEnd() at Cryptography.Cryption.Decrypt(String s) in F:\Comp\Crypt\Cryption.cs:line 96 at CryptSample.Form1.btnDecrypt_Click(Object sender, EventArgs e) in F:\Comp\Crypt\Form1.cs:line 230
I think it's somehow about the streamreader/writer (Am I right?) but i don't know how to fix it!!! anyway THANK YOU for your attention. Roshanak -
i need help with a cryptography exception!I have this code for encryption-decryption some data, when i run it, it makes the exception: "Padding is invalid and cannot be removed" I did everything i found in google or forums but none helped me. I appreciate any ideas! Please help me! This is the Code:
using System; using System.IO; using System.Text; using System.Security.Cryptography; public sealed class Cryption { private RijndaelManaged Algorithm; private MemoryStream memStream; private ICryptoTransform EncryptorDecryptor; private CryptoStream crStream; private StreamWriter strWriter; private StreamReader strReader; private string m_key; private string m_iv; private byte[] key; private byte[] iv; private string pwd_str; private byte[] pwd_byte; public Cryption(string key_val, string iv_val) { key = new byte[32]; iv = new byte[32]; int i; m_key = key_val; m_iv = iv_val; for(i=0;i<m_key.length;i++)> { key[i] = Convert.ToByte(m_key[i]); } for(i=0;i<m_iv.length;i++)> { iv[i] = Convert.ToByte(m_iv[i]); } } public string Encrypt(string s) { Algorithm = new RijndaelManaged(); Algorithm.BlockSize = 256; Algorithm.KeySize = 256; Algorithm.Padding = PaddingMode.PKCS7; memStream = new MemoryStream(); EncryptorDecryptor = Algorithm.CreateEncryptor(key,iv); crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Write); strWriter = new StreamWriter(crStream); strWriter.Write(s); strWriter.Flush(); crStream.FlushFinalBlock(); pwd_byte = new byte[memStream.Length]; memStream.Position = 0; memStream.Read(pwd_byte,0,(int)pwd_byte.Length); pwd_str= new UnicodeEncoding().GetString(pwd_byte); return pwd_str; } public string Decrypt(string s) { Algorithm = new RijndaelManaged(); Algorithm.BlockSize = 256; Algorithm.KeySize = 256; MemoryStream memStream = new MemoryStream(new UnicodeEncoding().GetBytes(s)); ICryptoTransform EncryptorDecryptor = Algorithm.CreateDecryptor(key,iv); memStream.Position = 0; CryptoStream crStream = new CryptoStream(memStream, EncryptorDecryptor, CryptoStreamMode.Read); strReader = new StreamReader(crStream); return strReader.ReadToEnd(); } }