Need to decrypt the file in windows 8 (VS 2012) and WP8.1(VS 2013).
I am decrypting a file which is already encrypted and working fine android app
I tried this code in Windows 8 using Visual Studio 2012.
public string pw = "3x5FBNs!";
public string AES_Decrypt(string input, string pass)
SymmetricKeyAlgorithmProvider SAP = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.AesEcbPkcs7);
CryptographicKey AES;
HashAlgorithmProvider HAP = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);
CryptographicHash Hash_AES = HAP.CreateHash();
string decrypted = "";
try
byte[] hash = new byte[32];
Hash_AES.Append(CryptographicBuffer.CreateFromByteArray(System.Text.Encoding.UTF8.GetBytes(pass)));
byte[] temp;
CryptographicBuffer.CopyToByteArray(Hash_AES.GetValueAndReset(), out temp);
Array.Copy(temp, 0, hash, 0, 16);
Array.Copy(temp, 0, hash, 15, 16);
AES = SAP.CreateSymmetricKey(CryptographicBuffer.CreateFromByteArray(hash));
IBuffer Buffer = CryptographicBuffer.DecodeFromBase64String(input);
byte[] Decrypted;
CryptographicBuffer.CopyToByteArray(CryptographicEngine.Decrypt(AES, Buffer, null), out Decrypted);
decrypted = System.Text.Encoding.UTF8.GetString(Decrypted, 0, Decrypted.Length);
return decrypted;
catch (Exception ex)
return null;
Its always through an error "Bad Data. (Exception from HRESULT: 0x80090005)"
Here is the Android code which is using for decrypt the same file
package com.enable;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.security.Key;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.net.util.Base64;
import com.enable.classes.Singleton;
import com.enable.classes.XMLPullParserHandler;
import com.enable.classes.XMLPullParserStringHandler;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.FrameLayout;
public class MainActivity extends DrawerActivity{//{//ActionBarActivity{//DrawerActivity{//{
public final static String SETTINGS_FILE = "settings_e3.xml";
public final static String SETTINGS_FILE_E = "settings.xml";
private ProgressDialog progressDialog = null;
CheckBox tncCheckBox;
@SuppressLint("InflateParams")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
FrameLayout frameLayout = (FrameLayout)findViewById(R.id.content_frame);
// inflate the custom activity layout
LayoutInflater layoutInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View activityView = layoutInflater.inflate(R.layout.activity_main, null,false);
// add the custom layout of this activity to frame layout.
frameLayout.addView(activityView);
// now you can do all your other stuffs
tncCheckBox = (CheckBox) findViewById(R.id.tncCheckBox);
//continue if the file is available and the terms and conditions are checked
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
boolean checkedStatus = preferences.getBoolean("TnCAgreed", false);
if(checkedStatus)
new ParseAndLoadTask().execute();
//load default settings
boolean useDefaultSetting = preferences.getBoolean("useDefaultSettings", true);
if(useDefaultSetting)
SharedPreferences.Editor editor = preferences.edit();
editor.putString("serverName", "Default 2Enable Server");
editor.putString("hostIP", "192.168.1.199");
editor.putInt("port", 21);
editor.putString("username", "2Enable");
editor.putString("password", "2En@ble2");
editor.putBoolean("ftpCheck", false);
editor.putBoolean("internetCheck", true);
editor.commit();
public void GetFTPDetails()
Intent intent = new Intent(MainActivity.this, GetFTPDetailsActivity.class);
startActivity(intent);
finish();
public void LoadTnC(View view) throws IOException {
Intent intent = new Intent(MainActivity.this, TnCActivity.class);
startActivity(intent);
finish();
public void LoadEssencePage(View view) throws IOException {
Intent intent = new Intent(MainActivity.this, EssenceActivity.class);
startActivity(intent);
finish();
/** Called when the user clicks the button
* @throws IOException */
public void ProceedToLearningArea(View view) throws IOException {
// Start a new thread that will download all the data
if(tncCheckBox.isChecked())
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("TnCAgreed", true);
editor.commit();
new ParseAndLoadTask().execute();
else
AlertDialog.Builder alertDialog = new AlertDialog.Builder(
MainActivity.this);
// Setting Dialog Message
alertDialog.setTitle("Cannot Proceed");
alertDialog.setMessage("Kindly read and accept the Terms and Conditions to Proceed.");
alertDialog.setCancelable(false);
// Setting Icon to Dialog
// Setting OK Button
alertDialog.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
alertDialog.show();
private String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
return sb.toString();
private static Cipher getCipher(int mode) throws Exception {
Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
//a random Init. Vector. just for testing
byte[] iv = "e675f725e675f725".getBytes("UTF-8");
c.init(mode, generateKey(), new IvParameterSpec(iv));
return c;
private static String Decrypt(String encrypted) throws Exception {
byte[] decodedValue = new Base64().decode(encrypted.getBytes("UTF-8")); // new BASE64Decoder().decodeBuffer(encrypted);
Cipher c = getCipher(Cipher.DECRYPT_MODE);
byte[] decValue = c.doFinal(decodedValue);
return new String(decValue);
private static Key generateKey() throws Exception {
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
char[] password = "3x5FBNs!".toCharArray();
byte[] salt = "S@1tS@1t".getBytes("UTF-8");
KeySpec spec = new PBEKeySpec(password, salt, 65536, 128);
SecretKey tmp = factory.generateSecret(spec);
byte[] encoded = tmp.getEncoded();
return new SecretKeySpec(encoded, "AES");
private class ParseAndLoadTask extends AsyncTask<String, Void, Void>
protected void onPreExecute (){
MainActivity.this.progressDialog = ProgressDialog.show(MainActivity.this, "Please Wait.", "Loading Data...", true, false);
protected Void doInBackground(String... args) {
try {
//check if the settings.xml file is available
File extStore = Environment.getExternalStorageDirectory();
File myFile = new File(extStore.getAbsolutePath() + "/2Enable/"+SETTINGS_FILE_E);
if(myFile.exists() && myFile.length()>0)
FileInputStream fileInputStream = new FileInputStream(myFile);
XMLPullParserStringHandler parser = new XMLPullParserStringHandler();
String data = convertStreamToString(fileInputStream);
try
String decrypt = Decrypt(data);
Singleton.setSettings(parser.parse(decrypt));
catch (Exception e)
e.printStackTrace();
else
AssetManager assetManager = getBaseContext().getAssets();
InputStream fileInputStream = null;
fileInputStream = assetManager.open(SETTINGS_FILE_E);
if(fileInputStream != null)
XMLPullParserStringHandler parser = new XMLPullParserStringHandler();
String Data = convertStreamToString(fileInputStream);
String decrypt = null;
try
decrypt = Decrypt(Data);
Singleton.setSettings(parser.parse(decrypt));
catch (Exception e)
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
return null;
//return "replace this with your data object";
protected void onPostExecute(Void result) {
if (MainActivity.this.progressDialog != null)
MainActivity.this.progressDialog.dismiss();
Intent intent = new Intent(MainActivity.this, LearningAreaActivity.class);
startActivity(intent);
finish();
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
return super.onOptionsItemSelected(item);
sandeep chauhan
Hi
Please provide your issue so that we can understand where you are facing issue.
For AES encryption please refer the msdn link
https://msdn.microsoft.com/en-us/library/system.security.cryptography.aesmanaged(v=vs.110).aspx
Regards
Varun Ravindranath Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you.
Similar Messages
-
I get to the file download window to install itunes and push run, but after it starts to install, it stops and I get an error message that installation can no continue and everything is uninstalled. It tells me to check with my software company to resolve. What does that mean?
Repair your Apple software update.
Go to START/ALL PROGRAMS/Apple Software Update. If it offers you a newer version of Apple Software Update, do it but Deselect any other software offered at the same time. Once done, try another iTunes install
If you don't find ASU, go to Control Panel:
START > CONTROL PANEL > Add n Remove Programs / highlight ASU and click CHANGE then REPAIR, -
Hi Friends,
I have a small issue to share with you.
My program fetches the payment file which is of .TXT, before that it was encrypted using external operating command, the command name is YDBCRYPT and the Operating system LINUX.
Now i need to decrypt the file to view the data how it can be done.
quick answer can be given points.
Advance thanks,
Chandra.Hi,
You cannot decrypt w/o knowing the encryption logic.
I believe you'll have to get the decryption logic from people who sent it to you and then implement it in report.
This report will first read it then decrypt it and then you can proceed for other processing.
Alternatively you can create a shell script in your own system with the decryption logic that should be provided to you and then after decrypting you can use this file.
Hope this clears the doubt
Regards
Nishant -
iTunes has tried to update itself and runs into an error and tells me to manually install. When I d/l and run the iTunesSetup.exe file I always encounter the following error message...
"A network error occured while attempting to read from the file C;|Windows|Installer|iTunes.msi" and iTunes does not update to iTunes 10.4.1.
Anyone know what is creating this error message? Thanks for the help...(1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
http://majorgeeks.com/download.php?det=4459
(2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
(3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
(4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
(5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time? -
ITUNES WILL NOT DELETE FROM ADD @ REMOVE PROGRAMS,
MESSAGE, READS a network error occured while attempting to read from the file C:WINDOWS\installer\iTunes.msiAll sorted now just needed to repair itunes from control panel
-
Sender file adapter is not picking the file from windows server
Hi Experts,
We have a sender file adapter running on Unix server. Now we have changed the source directory path from Unix to Windows in file access parameters. It is not picking the files from windows directory and not showing any error.
In this scenario, input file for sender adapter is *.xml and no content conversion.
Could any one please let me know is there anything needs to changed in file adapter.
Thanks in advance,
Sridhar. MSridhar,
What do you have in the directory path?
If it is a shared drive in unix then the directory in windows should also be a shared drive from XI system. Else if it is FTP check the address.
Regards,
---Satish -
Windows 2008 R2 - I just started receiving this when i log in, and also when i try to manage the machine:
MMC Cannot open the File:
C:\Windows\system32\ServerManager.msc
This may be because the file does not exist , is not an MMC console , or was created by a later version of MMC. This may also be be because you do not have sufficient access rights to the file.
This always worked before, and works for other users just not me on this particular box. This is a production box and i need a resolution quick please. Thanks in advance.
PMHas the system update readiness tool been run without error?
http://windows.microsoft.com/en-US/windows7/What-is-the-System-Update-Readiness-Tool
Then check the %SYSTEMROOT%\Logs\CBS\CheckSUR.log file for errors.
You can also try creating a new MSC
Start|Run|"mmc"|File|Add/Remove|Server Manager|Add|Local|OK|OK|File|Save As
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights. -
In 10.8, the file info window’s “Kind:” read “Application”/etc. for 64-bit items and “Application (32-bit)”/etc. for 32-bit items.
The “(32-bit)” part seems to have been lost in Mavericks. How do I determine if an item is 32 or 64-bit in Mavericks?1. Launch System Information into its 'report' mode. (A quick way to do this is by holding down the option key while clicking on the Apple menu item, which causes "About this Mac" to change to that.)
2. From the list on the left, under "Software" click on "Applications." (If you don't see the Applications item, click on "Show more information" from the "File" menu.)
3. Wait a minute or so for the report to finish.
4. The last column in the report is "64-bit (Intel)." (You may need to scroll the window to the right to see it.) Click on that heading to sort the list alphabetically. Anything with a "no" is 32 bit. -
My computer says that the file iTunes.cab its not good and that I need that to install the program, what is that?
I'm having the same problem. For what it's worth, I am running Windows 7 64-bit.
-
Script for transfer the file from windows to UNIX machine
Hi expert
1. I neeed one script that will transfer the files from windows machine to UNIX machine.
2. And the data updated in Windows file should also be update in UNIX file.
3. Please send me the steps how can i schedule this script.
Thanks in advance
Regards
FrndIt depends on what you need.
It's possible to use:
-winscp
But that means using a program to drag and drop files. This is most commonly used.
-setup samba on the unix system (the samba package/software needs to available for your unix)
This requires some setup on the unix system, and your windows system (connect the unix system and put a share defined on the unix system to a driveletter on your windows system), but lets you easily make a batchfile which copies data from one windows drive to another. A batchfile can be scheduled using 'at'. -
I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this
@Barbara – What purpose is that PDF for? Print? Web?
If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
A final resort to bring down file size is:
1. Print to PostScript
2. Distill to PDF
That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
I will place the PDF in InDesign, print to PostScript, distill to PDF.
Uwe -
while updating the older version iTunes to latest one it shows "a network error occurred while attempting to read from the file: C:\windows\installer\iTunes64.msi. pls help on this matter to connect my i5 to PC. Thanks in advance
(1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
http://majorgeeks.com/download.php?det=4459
(2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
(3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
(4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
(5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time? -
I am getting "a network error occurred while attempting to read from the file c:\windows\installer\itunes.msi" when I attempt to install itunes. Can anybody help me to resolve this issue?
You can try disabling the computer's antivirus and firewall during the download the iTunes installation
Also try posting in the iTunes forum since it is not an iPod touch problem. -
When I try to install Itunes, I get this error: (translated from Norwegian) There was a network error while trying to read from the file: C: \ windows \ installer \ iTunes.msi I have tried many times to reinstall, but nothing helps, please help me.
(1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
http://majorgeeks.com/download.php?det=4459
(2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
(3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
(4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
(5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time? -
Editing metadata in the file properties window
Hi,
I’m using Win XP SP3 on a “normal” Desktop-PC. Since my problem is not connected to hardware I think that description is enough but I do not know which software information is required. So you may ask. Important is maybe that I am running Adobe Acrobat and Reader simultaneously on the same machine.
The problem: I always changed and edited some of the metadata of my PDF files by bringing up the file properties window of the PDF (right click - properties). Next to the “General”-Tab is the “PDF”-Tab. You can see the title, author, topic, dates and PDF-Version of the document. The first four fields where always editable textboxes. I get used to put in some comments and other important information because I didn’t want to use any tool. Now the complete window is locked. Is this because of the new 9.3.3 Reader update? I updated so many times and never anything like this happened. How can I turn back to the old behavior?
I do not want to edit those information in Acrobat by choosing File and then propertis because it takes much more time because i have to open the file (if it is one its fine) but if there are more where the same info shall be in I'd like to use the built in function of the properties sheet in windows.
With kind regards
DragJoAt first I asked that question by mistake in the wrong forum so I put in it here. But it has been answered there http://forums.adobe.com/message/2973589
so I mark this as answered, too.
Maybe you are looking for
-
My pictures won't show up in my messages I just get a grey box that tells me it's a JPEG
WHen I go to my messages I can't see photis. I only get a grey box that says which picture it is and that its a JPEG. Is there away to get them back? I have a 5s and iOS 8.2.
-
How do I download i-tunes 11.1 with a Mac from 2006 with OS X 10.5.8?
How do I download i-tunes 11.1 into a 2006 Mac with os x 10.5.8?
-
How to adjust the font size of iPad in printing a web page.
How to adjust the font size of iPad printout of web pages ?
-
I have a 20" Apple Cinema Display that seems like it's losing it brightness. The display is used everyday and is about 5 years old. How can I tell if the brightness is normal or has faded?
-
Won't finish downloading 7.4.2
I just bought the new ipod nano anhd have had the second gen for almost a year. Wehnever i try downloading the uns the regualr window comes up and i got through the download process but at the end it says " Itunuered unknown errors while downloading"