Convert Below Java code equivalent to c# windows store app.

Hi
please help me " To convert Below Java code equivalent to c# windows store app."
private String SecretKey = "enctsbqrm6hxyjfa";
    public byte[] encrypt(String text) throws Exception
        if(text == null || text.length() == 0)
            throw new Exception("Empty string");
        // convert key to bytes
        byte[] keyBytes = SecretKey.getBytes("UTF-8");
        // Use the first 16 bytes (or even less if key is shorter)
        byte[] keyBytes16 = new byte[16];
        System.arraycopy(keyBytes, 0, keyBytes16, 0, Math.min(keyBytes.length, 16));
        // convert plain text to bytes
        byte[] plainBytes = text.getBytes("UTF-8");
        // setup cipher
        SecretKeySpec skeySpec = new SecretKeySpec(keyBytes16, "AES");
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
        //byte[] iv = new byte[16]; // initialization vector with all 0
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
        // encrypt
        byte[] encrypted = cipher.doFinal(plainBytes);
        return encrypted;
  Thanks            
  Nitin

Hello Nitin,
Your current requirement is beyond the scope of our support for this fourm which is used to Discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection.
If you want to know how to encrypt/decrypt in windows store app, I suggest that you could post a it to:
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/home?forum=winappswithcsharp
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to convert these java codes (for a feedback) to javabean?

    Can anyone please help me to convert these java codes (for feedback) to javabean using the MVC Model-View-Controller pattern design?
    <%
    //instantiate variables
    Connection con = null;
    Statement stmt = null;
    Statement stmt2 = null;
    ResultSet rs = null;
    String queryString;
    int newInBoxMsg = 0;
    int newSentMsg = 0;
    int newSavedMsg = 0;
    int newTrashCanMsg = 0;
    String currentUserID = 1+"";
    String adminID = 1+""; //change this ID to your adminID in the db
    try
    //Load the JDBC driver
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    //Get the connection getConnection("access driver", "userID", "password")
    con = DriverManager.getConnection("jdbc:odbc:FREN_DB","","");
    stmt = con.createStatement();
    //sql statements: create, update, query
    Calendar cl = Calendar.getInstance();
    %>
    <%
    if(request.getMethod()=="POST"){
                   int y = stmt.executeUpdate("INSERT into Feedback(`whom`, `msg`, `date`)"
                   +" values ('"+currentUserID+"', '"+request.getParameter("date")+"', '"
                   request.getParameter("msg")"')");
                   int x = stmt.executeUpdate("INSERT into MailBox(`whom`, `who`, `mailheader`, `mailbody`, `date`)"
                   +" values ('"+adminID+"', '"+currentUserID+"', 'Feedback', 'We have received your feedback and we will respond to you as soon as possible', '"+request.getParameter("date")+"')");
                   out.println("Feedback Sent!");
    else {
    %>
    <form name="compose" method="POST" action="Feedback.jsp">
    <input name="date" type="hidden" value="<% out.println(cl.get(cl.DAY_OF_MONTH)+"/"+cl.get(cl.MONTH)+"/"+cl.get(cl.YEAR)); %>" maxlength="20">
    <p>Your Feedback</p>
    <p>
    <textarea name="msg" cols="50" rows="10"></textarea>
    </p>
    <p>
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    <%
    }catch(Exception e) {
    System.out.println(e);
    %>

    Okay, first suggestion is to never create database connections in JSP/Servlet. SInce you mentioned MVC, JSP is the View, and a servlet can be the controller to process requests and redirect accordingly.
    This piece of code should be in a class invoked from the model layer (business logic components) preferably with some abstraction. Maybe you should search around for DAO pattern. That might give you an idea.

  • Code signing Windows Store Apps

    I can't get a very clear answer on the code signing requirement for deploying Windows Store Apps to the app store, even after searching the Internet for a couple of days. Specifically, my question is: are you required (not just recommended) to have a third
    party Code Signing Certificate to publish to the Windows App Store?
    I am not distributing the app to internal customers, but rather to external customers via the app store. If I'm missing this requirement documented in the documentation available on this site, can you point me to it?
    Michael

    All methods of deployment (Windows Store, PowerShell or System Center Configuration Manager) require the application to be signed using a certificate. The Windows Store channel requires a signing certificate
     from a publicly trusted CA because, well, the testers in the approval process won't have access to your internal PKI.
    Visual C++ MVP

  • How to find out if the company account for developing windows store apps is verified/approved?

    We have created the account for windows store app. How can I find out if the account was approved (the identity of the company)? 

    Hi,
    There is one more method,i know
    Set the JAVA_HOME and PATH
    then execute the
    $WL_HOME\wlserver_10.3\server\bin>setWLSEnv.cmd
    Go to directory which contains weblogic.jar ($WL_HOME\server\lib) and run below command
    $WL_HOME\wlserver_10.3\server\lib>java -cp weblogic.jar weblogic.version
    WebLogic Server 10.3.4.0 Fri Dec 17 20:47:33 PST 2010 1384255
    Hope this will be helpful,
    Regards
    Fabian

  • How to use offline map for windows store app using c# and xaml

    Hi friends,
    I want to integrate offline map in my windows store app but I am not able to achieve that.
    Below is my requirement:
    When a user wants to go somewhere where she/he doesn't want to use wi-fi or mobile data but wants to use map to assist her/him to roam around. For this I want to give an option to download the map for that region/area before leaving for that place and there
    she/he can use map even in offline.
    Is it possible that I can achieve this using Bing maps?
    If yes then tell me the processes to follow.
    If no then can I achieve this using "Here" or by using any other API or by tweaking any way?
    Note: I am showing maps in case of online and user can search for directions or any places in that. I am using Bing maps for that.
    Thanks,
    S.Sandeep

    Hi Sandeepmsandy,
    There is no available code sample for this scenario. You may write your own.
    Step 1: Get pdf URL from sqlite database. Please refer to the following MSDN blog and see a code sample.
    http://blogs.msdn.com/b/robertgreen/archive/2012/11/13/using-sqlite-in-windows-store-apps.aspx. Note, you need to retarget the project to 8.1 and then get two sqlite packages from NuGet before building this sample.
    Step 2: Use some special classes to get file from serer.
    HttpWebRequest can help download small pdf files. For more information to see
    https://social.msdn.microsoft.com/Forums/windowsapps/en-US/de96a61c-e089-4595-8349-612be5d23ee6/download-file-with-httpwebrequest?forum=winappswithcsharp. It’s easy for use, but if you want to download the larger or many files, it’s recommend to use
    BackgroundTransfer namespace. The classes in this namespace provide a power way to transfer files in the background. See a code sample from MSND.
    https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

  • Integrate existing VB database with windows store app

    Hi
    Can I integrate a VB Database Access 2007 with a Windows 2008 store app?
    If yes, can I have a hyperlink that retrieves a search inside this database and goes directly to a page created by this database?
    Imagine that I have an e-book with a table of contents where I have several hyperlinks for a query that shows me a specific poem and image inside a page.
    Is there a sample?
    thanks

    Hi Rui - there are no APIs that will connect to an Access database directly within a Windows Store app. You can convert the database to SQLite, or provide a web-based interface to the Access database in order to retrieve/update the data.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • Login to WebApi (MVC + WebApi) with Microsoft Account from Windows Store App

    Hi
    How can I access a WebApi Controller (ASP.NET MVC+WebApi) that is secured with Microsoft Account from a Windows Store App?
    I have no idea how to login. I tried the LiveSDK but this gives me only access to OneDrive, Callender and so on.
    Could someone please point me in the right direction.
    Thanks
    Guenter

    Hi Guenter,
    To be clear, you are using Microsoft account as login and at same time you have your own REST service for other functionalities?
    Let's say if you login with LiveSDk, you should be able to get some access token, see this for more information:
    Signing users in, after that use the token to access your REST service, as I understand REST service is a kind of http request, we can use HTTPClient to request data from the address.
    I'm afraid there is no existing sample here but the only thing I found is HTTPClient sample:
    https://code.msdn.microsoft.com/windowsapps/HttpClient-sample-55700664, you can use POST to send your token information to the server.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Distributing multiple versions of an app within a single Windows Store app

    The company I work for creates Point Of Sale (POS) software using Software As A Service (SAAS), so we host our clients' databases.  We do not force all of our clients to all be on the same version of our software; i.e. some clients are on version 3,
    others v4, others v5, etc.  As you would expect, the database schema for each of these versions is different, so each of these clients also use a different version of our client-side app.
    We are looking at making a Windows Store app that acts as a light-weight POS app that clients can use to sell their products.  The problem is, we will require having multiple versions of our Windows Store app in production; the version of the app that
    the client uses must correspond to their database version.  We were initially hoping to have our Windows Store app detect which version of the app the client should be using, and then automatically update itself to the correct version, but
    were told on this post that it violates the Windows Store certification criteria, so that's not an option.
    It has been suggested that we put multiple apps into the Store; one for each version of our software. We really don't want to do this though, as when we upgrade a client's database from one version to the next it would require that they uninstall their current
    app and install the newer versions app, causing them to lose all of their custom settings. We would like the updates to remain as transparent to the end users as possible; the store clerk shouldn't need to worry about which version their database is on so
    they know which app to download from the Store.
    As a possible workaround, is it ok for us to package all 3 versions of our app into a single Windows Store app, and then just have the app check at runtime which version it should run?  I assume that this is alright, since we will not be downloading
    any other code or installing any software/apps, as was the case with our original solution that violates the certification criteria.  Essentially we would just have 3 different classes and determine at run-time which classes code we should run. 
    I know that this solution isn't ideal, as it means our app will be 3 times larger than it needs to be, and that an update to any one of the 3 versions of our software will require an update to the Store app (so potentially users may download a new version
    of the Store app, even though it doesn't have any changes for the particular code version (i.e. class) that they will use), but it's one of the best alternatives we have come up with.  I just want to check that this solution doesn't also violate any certification
    criteria before we go down this road.
    If this is not allowed then our only other alternative might be to go with sideloading (as
    I discuss on this thread) and avoid using the Windows Store all together, but we would prefer to use the Store if possible as it eliminates a lot of overhead that we would have to deal with if we use sideloading.
    Any insights or suggestions that you can give are appreciated. Thanks!
    - Dan - "Can't never could do anything"

    Hey Mr_bigworlds, thanks for the reply.  The moderator on this post actually told me that this
    would be a better forum for my inquiries.  I agree that there may be another forum better suited for this question (there are so many that I don't know about), but since this relates to Windows Store certification criteria, I don't think the Windows Desktop
    Development forums are the place for it.
    - Dan - "Can't never could do anything"

  • TelemetryClient.TrackException Does Not Include Method Name Or Call Stack (Windows Store App)

    We are attempting to use Application Insights (v0.12.0-build17386) for our Windows Store App.  When we use TelemetryClient.TrackException, no details appear in the azure portal.  The Failed Method is "Could Not Parse" and the Call Stack
    is empty. If we click on the "..." it gives more details but still no method name or call stack information to help us determine where the exception was thrown.  Is this by design, not implemented, or did we miss something obvious?  The
    code is very simple:
    public static void LogException(Exception exception)
    TelemetryClient telemetryClient = new TelemetryClient();
    telemetryClient.TrackException(exception);

    This is a known limitation of this version. It is in the backlog to fix. Note though that 0.13 is out already and fix should be included in the next version (0.14)
    Anastasia

  • How to display the PPT, PDF, XL, DOC files with in the Windows store app?

    Hi,
    I would like to display the PPT, PDF, XL, DOC files with in the Windows store app? is there any controls provided by Microsoft to view these files with in the app?
    Or
    Any workaround to achieve the desired functionality?
    Kindly provide your inputs if any one has.
    Regards
    Prasad

    Hi Prasad,
    As I know currently there is no in-build functionality to display the PPT, XLS or DOC file directly on the Windows Store App, but you can always open these files by
    Launcher class
    However a good news is we can display PDF on Windows Store App by
    Windows.Data.Pdf class, see this for more information:
    https://code.msdn.microsoft.com/windowsapps/PDF-viewer-showcase-sample-39ced1e8/
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Image file can't be opened by windows store app if the file is in the Ext4's external hard disk.

    My question is described below:
    I have two disks, external hard disk and removable disk. They are formatted with EXT4.
    I put the same image in the disks, and use Ext2Fsd to mount the disks.
    I open the file in win8, and it will default open by the windows store app : photos.
    It will be success to open if the file is in the Ext4's removable disk.
    It will be failed to open if the file is in the Ext4's external hard disk.
    I don't know why it will be failed to open if the file is in the Ext4's external hard disk.
    Does anyone have similar experiences?

    Hi hatasum,
    Thanks for posting!
    Base on my experience, if installed Ext2Fsd, we can read the ext4 file system on windows system. But Which version of Ext2Fsd did you use? From my experience, Ext2Fsd is not spported fine  about windows 8 version. Please refer to this software official
    website (http://www.ext2fsd.com/ ) . I suggest you could post this issue to the Ext2Fsd discussion forum ( such as
    http://sourceforge.net/p/ext2fsd/discussion/143329/thread/7f262ad0/ )for better help.
    Thanks for your understanding.
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Tabbed page in a Windows Store App

    I am creating a Windows 8.1 app (Windows Store App) and I need to have a tab-based page in this app. As an example, for adding a new contact, I need to group the new contact details in tabs which can be switched from the left side
    menu items.
    I tried to use a FlipView for this purpose but I don't want the users to be able to switch between pages by flipping. I want to create a page similar to
    [Add a recipe] page in Microsoft Food & Drink app.
    How can I do this?

    You can create a Page that contains a
    Frame and switch out the frame as each menu item is clicked.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • System.ExecutionEngineException in a Windows Store App? - Why?

    Hoping for some help from the powers that be or other resident experts, as I think this is one tricky problem.
    I'm getting some seemingly random System.ExecutionEngineException events in my Windows Store app. Even though the error message itself is less than useless, when enabling native code debugging there does seem to be a connection to the use of streams and
    possibly thread blocking. The call stack almost always contains a reference to SHCreateStreamOnFileW or similar stream-related functions (although that particular call is unsupported in WinRT, I'm assuming the kernel is calling it under the hood; I certainly
    am not).  In my own code, I do indeed utilize CreateStreamOverRandomAccessStream though so there's an obvious possible connection there.
    I cut back on what was probably overly conservative use of EnterCriticalSection calls and that seems to have eliminated *almost* - but not all - of these insidious errors. Therefore I'm wondering if there's a connection between these errors and possible
    thread blocking or competing locks? They also definitely seem to occur only when disk access is sluggish. So again, I'm thinking some issue with thread blocking while waiting for the disk. But just a guess.   
    What's particularly confusing is that the docs say this exception is obsolete, so I don't understand why I'd be getting it in a Windows store app. 
    Any insight would be appreciated!
    Thanks,
    Peter

    You know what? I was just telling one of my testers today that I've only ever had an issue on my one laptop and no other machines. And he's never experienced it. (Outside the dev environment if just manifests as a random app crash and he hasn't reported
    anything like that). Thing is the laptop is basically fine otherwise. Certainly no random app crashes except my own app. A few other data points. It only manifests in release mode so far. I've never seen it in debug mode. (Maybe code optimization could be
    contributing?) I am using a fair amount of C#/C++ interop and a lot of multithreadimg. When the crashes do occur they are always when the app is doing things that use the C++ modules and specifically they utilize COM streams (which I implement
    in C# to wrap .net streams) and synchronous disk read ops. IStream specifically. But the modules are always called from worker threads. They never block the UI thread. So that shouldn't be the issue. Even if it is my environment there should be a graceful
    way to handle the error. As I said other apps don't just crash. Trying to think of what other relevant information I can give without getting into gory and irrelevant detail. Again any other insights appreciated. I'll try to grab a stack history next time
    it happens (I have to be in native mode debugging to get any useful info). that will reveal more. Thanks so much. Peter

  • Reading electronic identity cards in a windows store app project

    In a windows store app project, i've been ask to implement a way to read the information on a Electronic Identity card such as this
    is there any API i can use on a windows Store App project to achieve this? can't seem to find anything of sorts

    You would have to be able to tap into a reader with a driver which returns the information back to the app.  Do you have this?
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • How to run windows store app in windows tablet

    Hi,
    I am developing an windows store app I can run my app in local machine.How can i run my app on windows tablets. I am using ASUS windows 8 tablet .How can I connect tab to my pc and run myapp in tablet.
    Thanks,
    Alok

    1) In Visual Studio, create an appx package (Project -> Store ->Create App packages -> Not for upload)
    2) Zip up the folder of the app package
    3) Send to target machine
    4) Unzip app package
    5) Right-click Add-AppDecPackage.ps1 -> Run with Powershell (must be an admin)
    6) Follow prompts for install
    7) Enjoy
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

Maybe you are looking for

  • How can I connect my mac book pro to my tv?

    Hi, I would like to connect my macbook pro to my TV. On my macbook pro i have the following connectors: Thunderbolt FireWire 800 On my TV I have 3 HDMI connectors. Which cable and/or adaptator solution exist? Regards, Kalen

  • Consuming a WebService

    Hi All, Im following this help doc to build an application to consume a webservice. http://help.sap.com/saphelp_nw04/helpdata/en/81/12703e5da3e946e10000000a114084/frameset.htm What I want to understand is the following : In point no 7. What configura

  • HP 530 notebook PC - hard drive and RAM upgrade

    Hello, I'm using HP 530 and I want to upgrade it's hard drive. In documentation specified that my notebook supports only 80/120Gb hard drives and up to 2Gb RAM. Is it true? Can't i use more capacious HDD or RAM. And what type of HDD i should by? Is i

  • How can I turn off Automatic White Balance/Correction?

    Hi, I shoot color Infra-Red images. White Balance is handled in Camera - and then in Photoshop. As a new user to Lightroom 2 - everytime I view/click on an image in the Library - the color/balance of the image changes to a deep red, and I lose all of

  • TS3367 Trouble With FaceTime On iPad Mini

    I have a new iPad Mini.  I have turned on FaceTime in Settings and loaded new contacts who have existing iPads of iPhones.  When I try to connect with FaceTime, it gives the message that "FaceTime is turned off in Settings.  Do you want to turn it on