Convert Data encryption code from VB to Java.

Can anyone help me in converting the following code from VB to Java?
'Purpose: This function decrypts the password of the user in the database so that
' it can be matched accurately with the inputted password of the user in
' the Log-In form (Case-sensitive)
'Function to decrypt password
Public Function Decrypt(ByVal Encrypted As String)
On Error GoTo ErrorRoutine
For intEncryptDecrypt = 1 To Len(Encrypted)
strLetter = Mid(Encrypted, intEncryptDecrypt, 1)
Mid(Encrypted, intEncryptDecrypt, 1) = Chr(Asc(strLetter) - 1)
Next
Decrypt = Encrypted
Exit Function
ErrorRoutine:
Err.Raise Err.Number, , Err.Description
Exit Function
End Function

hi,
try this
public String decrypt(String a){
    for(int i=0;i<a.length();i++){
      char c=a.charAt(i);
      c--;
      a=a.substring(0,i)+c+a.substring(i+1);
  return a;
}regards

Similar Messages

  • Function Module to convert date to week from Sunday to Saturday

    Hi,
    In BW the convertion date to week always give week from Monday(1) to Sunday(7)
    I'm looking for a function module to convert date to week from Sunday(1) to Saturday(7)
    Thanks
    Sebastien

    Hi,
    I think this SAP standardized. Maybe you need to create custom FM.
    You can copy SAP FM DATE_GET_WEEK. in the FORM FIRSTWEEK, I see below case,
    CASE start_weekday.
        WHEN if_calendar_definition=>c_monday.
          start_weekday_number = 1.
        WHEN if_calendar_definition=>c_tuesday.
          start_weekday_number = 2.
        WHEN if_calendar_definition=>c_wednesday.
          start_weekday_number = 3.
        WHEN if_calendar_definition=>c_thursday.
          start_weekday_number = 4.
        WHEN if_calendar_definition=>c_friday.
          start_weekday_number = 5.
        WHEN if_calendar_definition=>c_saturday.
          start_weekday_number = 6.
        WHEN if_calendar_definition=>c_sunday.
          start_weekday_number = 7.
      ENDCASE.
    Maybe you can play something here.

  • Any solution for preventing converted data (to excel) from crashing?

    Any solution for preventing converted data (to excel) from crashing - file crashes on a consistent basis.

    Hi Shrinivas,
    LabVIEW is getting bug fixes and new features with each version step.
    But new features also can bring new bugs - and not all bugs from older versions are fixed by now…
    The MixedSignalGraph is a beast of it's own and known to have bugs inside. The one you noticed now is probably one of those.
    So it's not your fault your VI terminates rather "unhappy", but most probably NI's fault. You can have a workaround as described in the last post.
    If I have to take same data from wire as you mentioned, I need to save the data in some variable
    No, you don't need any "variable"! THINK DATAFLOW: the wire is the variable!
    I have to write the data to excel file using report generation tool kit or some other way. … Please let me know if I can do it in some other easy methods. 
    It all depends on the datatype of your data. There are functions to save to spreadsheet files. You can save in binary files. You can create TDMS files , which can be read by Excel too. All those functions are really easy to use - you just have to look at the example VIs coming with LabVIEW!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Compiling java code from a running java application

    How does compiling of java code from a running java application work?
    I found a class: com.sun.tools.apt.main.JavaCompiler
    but cannot find any documentation of how this class works.

    How does compiling of java code from a running java
    application work?Probably most reliably using Runtime.exec().
    I found a class:
    com.sun.tools.apt.main.JavaCompiler
    but cannot find any documentation of how this class
    works.For a purpose. You are not supposed to use this class. With the next JRE release or implementation, it might not exist anymore - it's not part of the standard API.

  • Need help for converting c# encryption code to javascript

    I have this below code in c# i need to convert it into nodejs i would really appriciate some help in this.
    Rfc2898DeriveBytes passwordDb2 = new Rfc2898DeriveBytes(passphrase, Encoding.ASCII.GetBytes(DeriveSalt(grains)));
    byte[] nonce = passwordDb2.GetBytes(NonceSize);
    AesManaged symmetricKey = new AesManaged { Mode = CipherMode.ECB, Padding = PaddingMode.None };
    _encryptor = symmetricKey.CreateEncryptor(_nonces[0], null);
    public byte[] Encrypt(byte[] plainText, int blockIndex)
    byte[] nonceEncrypted = new byte[NonceSize];
    byte[] outputData = new byte[_chunkSize];
    _encryptor.TransformBlock(_nonces[blockIndex], 0, NonceSize, nonceEncrypted, 0);
    for (int i = 0; i < _chunkSize; i++)
    outputData[i] = (byte)(plainText[i] ^ nonceEncrypted[i % NonceSize]);
    return outputData;
    public byte[] Decrypt(byte[] encryptedText, int blockIndex)
    byte[] nonceEncrypted = new byte[NonceSize];
    byte[] outputData = new byte[_chunkSize];
    _encryptor.TransformBlock(_nonces[blockIndex], 0, NonceSize, nonceEncrypted, 0);
    int index = 0;
    for (int i = 0; i < _chunkSize; i++, index++)
    if (index == NonceSize)
    index = 0;
    outputData[i] = (byte)(encryptedText[i] ^ nonceEncrypted[index]);
    return outputData;
    Currently i have the below code from what i understood (I am quite new to nodejs)
    var crypto = require("crypto");
    var nonce = crypto.pbkdf2Sync(passphrase, "grains", 1000, NonceSize);
    _encryptor = crypto.createCipheriv('aes-128-ecb', binkey, "");
    _decryptor = crypto.createDecipheriv('aes-128-ecb', binkey, "");
    Encrypt: function (plainText, blockIndex) {
    var nonceEncrypted = [NonceSize];
    var outputData = [_chunkSize];
    var crypted = Buffer.concat([_encryptor.update(plainText), _encryptor.final()]);
    for (var i = 0; i < _chunkSize; i++) {
    outputData[i] =(plainText[i] ^ nonceEncrypted[i % NonceSize]);
    var x = new Buffer(outputData);
    return x;
    Decrypt: function (encryptedText, blockIndex) {
    var nonceEncrypted = [NonceSize];
    var outputData = [_chunkSize];
    var decrypt = Buffer.concat([_decryptor.update(encryptedText), _decryptor.final()]);
    var index = 0;
    for (var i = 0; i < _chunkSize; i++, index++) {
    if (index == NonceSize)
    index = 0;
    outputData[i] = (encryptedText[i] ^ nonceEncrypted[index]);
    var x = new Buffer(outputData);
    return x;

    Maybe, you should post to the Javascript secition of the ASP.NET forum.
    http://forums.asp.net/

  • How can I convert date in FOX (from DEC to date[DEC])

    Hi everyone!
    In my planning layout I have a field called "MYDATE" of the date-type "DEC: Calculation or amount field with comma and +/- sign" (-> BPS does not allow using DATS as date-type).
    Since I import that date from a different system, I have to use a temporary workaround field "WADATE" (WorkaroundDate) of type DEC (alternatively integer or float) which contains the date in a format YYYYMMDD (e.g. 20070604).
    How can I transfer the date from WADATE to MYDATE? I tried using FOX, but for some reason it does not work. When I use the following function, MYDATE remains empty:
    DATA TMPDATE TYPE F.
    DATA MYPROJECTS TYPE B906_PROJ.
    FOREACH MYPROJECTS.
    "MYDATE" is the field I want my date in
    "WADATE" is my workaround field that contains the date
    TMPDATE = {WADATE,000,0000000001,0000000001,001}.
    BREAK-POINT.
    {MYDATE,000,0000000001,0000000001,001} = TMPDATE.
    ENDFOR.
    Is it possible to solve my problem with FOX? Or do I have to work with an EXIT function?
    Best regards, Daniel

    Daniel,
    The better approach is the one Marc said but if you have tomake a work around work, I think you might need to try and define your temporary date variable as String and another for the converted date as of type of the final date.  I would not define any date type as float unless you can have part days and it is very important to have part days, integer might work by I would try String first myself.
    It has been a while but on a BW 3.5 project I had to do some manipulation to read the attribute value of material master data to get the launch date and use it to derive the start period (definited as type 0FISCPER) and proportion of month based on number of days remaining after launch date vs the # of days for the month.  I think I used string type function in FOX to derive some of the component...
    Hope this helps,
    mary

  • How can i take off encryption code from itunes for iphone?

    "Encrypt iphone Backup" option got selected on itunes by me while ago  when i hooked my iphone with my computer the first time. Now i can backup my iphone on itunes but cannot restore that backup or any backup on my iphone because i don't remember that encrypted code. whien i try to deselect this option still it asks for the code.
    I got stuck now, what to do..?
    Please help..

    Hi Saini22,
    You may be able to recover the encrypted backup of you iPhone using the suggestions in this article -
    iOS: Troubleshooting encrypted backups - Apple Support
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • Generate and print data matrix code from a vi

    Folks,
    does anyone know how to code a string into a data matrix code? How can the code be printed most straightforward? Probably it's the best way to generate the code in an image or picture format and send it to the printer that way? The printer we are using is a barcode printer, not an usual laser printer. According to the specifications this printer is able to print data matrix codes. Unfortunately, the vendor of the printer wants the user to use the proprietary software and does not provide a LabVIEW driver.
    Thanks for any hint,
    P.

    Hi
    I think the Dymo Labelwriter is a general purpose printer. So you may send data as you do to any printer. Her is a link to free barcode kit for labview http://code.google.com/p/lvbarcode/downloads/list
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • How to convert Data Decryption coded in VB to Java

    Hi! Can anyone help me on converting the following VB code to Java?
    'Purpose: This function decrypts the password of the user in the database so that
    ' it can be matched accurately with the inputted password of the user in
    ' the Log-In form (Case-sensitive)
    'Function to decrypt password
    Public Function Decrypt(ByVal Encrypted As String)
    On Error GoTo ErrorRoutine
    For intEncryptDecrypt = 1 To Len(Encrypted)
    strLetter = Mid(Encrypted, intEncryptDecrypt, 1)
    Mid(Encrypted, intEncryptDecrypt, 1) = Chr(Asc(strLetter) - 1)
    Next
    Decrypt = Encrypted
    Exit Function
    ErrorRoutine:
    Err.Raise Err.Number, , Err.Description
    Exit Function
    End Function

    http://forum.java.sun.com/thread.jsp?forum=54&thread=208636

  • Converting data volume type from LINK to FILE on a Linux OS

    Dear experts,
    I am currently running MaxDB 7.7.04.29 on Red Hat Linux 5.1.  The file types for the data volumes were
    initially configured as type LINK and correspondingly made links at the OS level via "ln -s" command. 
    Now (at the OS level) we have replaced the link with the actual file and brought up MaxDB.  The system
    comes up fine without problems but I have a two part question:
    1) What are the ramifications if MaxDB thinks the data volumes are links when in reality they are files.
        (might we encounter a performance problem).
    2) In MaxDB, what is the best way to convert a data volume from type LINK to type FILE?
    Your feedback is greatly appreciated.
    --Erick

    > 1) What are the ramifications if MaxDB thinks the data volumes are links when in reality they are files.
    >     (might we encounter a performance problem).
    Never saw any problems, but since I don't have a linux system at hand I cannot tell you for sure.
    Maybe it's about how to open a file with special options like DirectIO if it's a link...
    > 2) In MaxDB, what is the best way to convert a data volume from type LINK to type FILE?
    There's no 'converting'.
    Shutdown the database to offline.
    Now logon to dbmcli and list all parameters there are.
    You'll get three to four parameters per data volume, one of them called
    DATA_VOLUME_TYPE_0001
    where 0001 is the number of the volume.
    open a parameter session and change the value for the parameters from 'L' to 'F':
    param_startsession
    param_put DATA_VOLUME_TYPE_0001 F
    param_put DATA_VOLUME_TYPE_0002 F
    param_put DATA_VOLUME_TYPE_0003 F
    param_checkall
    param_commitsession
    After that the volumes are recognizes as files.
    regards,
    Lars
    Edited by: Lars Breddemann on Apr 28, 2009 2:53 AM

  • Transfer source code from visual age java to sun java studio creator

    How can i transfer my souce code that was writen in visual age java 4.0 version to sun java studio creator

    Hi,
    You can try the following:
    From the File menu choose Add Existing Item. Under this option you have Web page, Image file, Stylesheet, Java source and Other files. This should allow you to add existing items.
    I hope this helps
    Cheers
    Giri :-)
    Creator Team

  • How to convert data when transferring from one table to another

    I have two tables and these are the structure of the tables
    create table E1(
    ID NUMBER
    ,NAME VARCHAR2(30)
    , DESIGNATION VARCHAR2(30)
    ,GENDER VARCHAR2(10));
    create table E2(
    ID NUMBER
    ,NAME VARCHAR2(30)
    , DESIGNATION VARCHAR2(3)
    ,GENDER NUMBER); Now I want to transfer records from one table to another using a master tables where data are compared because the datatypes in tables are different
    The first one is a gender table to match the gender and convert
    create table Gender(
    E1 varchar2(10),
    E2 number);The second is for the designation
    create table Designation(
    E1 varchar2(30),
    E2 varchar2(3);How to match and convert the data so that it can be transfered.

    Peeyush wrote:
    Can we do it with the help of a cursor.
    All SQL executed by the database are parsed as cursors and executed as cursors.
    I mean I have to insert data in bulk and I want to use cursor for it.The read and write (select and insert) are done by the SQL engine. The read part reads data and passes it to the write part that inserts the data.
    Now why would using PL/SQL and bulk processing make this faster? It will reside in-between the read part and the write part being done by the SQL engine.
    So the SQL engine reads the data. This then travels all the way to the PL/SQL engine as a bulk collect. PL./SQL then issues an insert (the write part to be done by the SQL engine). And now this very same data travels all the way from the PL/SQL engine to the SQL engine for insertion.
    So just how is this approach, where you add extra travel time to data, faster?
    and i want to commit the transaction after every 50 recordsWhy? What makes you think this is better? What makes you think you have a problem with not committing every 50 rows?

  • Convert simple animation code from as2 to as3

    Hi everyone,
    I have a simple animation that is controlled by the y movement of the mouse. The code for the animation is put in frame 1 and is as follows:
    var animationDirection:Boolean = false;
    var prevMousePosition:Boolean = false;
    var mouseListener = new Object();
    mouseListener.onMouseMove = function () {
    var curMousePosition = _ymouse;
    if(curMousePosition > prevMousePosition) {
    animationDirection = false;
    }else if(curMousePosition < prevMousePosition) {
    animationDirection = true;
    prevMousePosition = curMousePosition;
    Mouse.addListener(mouseListener);
    function onEnterFrame() {
    if(animationDirection && _currentframe < _totalframes) {
    nextFrame();
    }else if(!animationDirection && _currentframe > 1) {
    prevFrame();
    Is it possible to use this code in as3 or do I need to convert it? I am grateful for any help. Best wishes

    Yes, you need to convert the code. Here is what looks like a similar logic in AS3:
    import flash.events.Event;
    import flash.events.MouseEvent;
    var animationDirection:Boolean = false;
    var prevMousePosition:Boolean = false;
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
    function onMouseMove(e:MouseEvent):void {
        var curMousePosition = mouseX;
        if (curMousePosition > prevMousePosition)
            animationDirection = false;
        else if (curMousePosition < prevMousePosition)
            animationDirection = true;
        prevMousePosition = curMousePosition;
    function onEnterFrame(e:Event):void
        if (animationDirection && _currentframe < _totalframes)
            nextFrame();
        else if (!animationDirection && _currentframe > 1)
            prevFrame();

  • How do I convert the following code from crystal reports to Reporting Services?

    stringvar rbt := "";
    if { param} = -1 then rbt := "ALL | " else rbt := {rptStoreMasterByDC;1.RegionName} + " | ";
    if {param2} = -1 then rbt := rbt + "ALL | " else rbt := rbt + {rptStoreMasterByDC;1.BranchName} + " | ";
    if {param3} = -1 then rbt := rbt + "ALL" else rbt := {rptStoreMasterByDC;1.TerritoryName};
    rbt

    Add a customer code in the report. Call it from the report tablix cell using expression. Pass param,param2,param3, RegionName, BranchName, TerritoryName as parameters of the custom function/procedure.
    Refer http://technet.microsoft.com/en-us/library/ms156028.aspx
    The custom code will look like as below.
    Public Function ChangeWord(ByVal param As Integer,ByVal param2 As Integer,ByVal param3 As Integer,ByVal RegionName As String,ByVal BranchName As String,ByVal param As Territory) As String
    Dim s as string
    If param = -1 then s = "ALL |" else s = RegionName & "|"
    If param2 = -1 then s = s & "ALL |" else s = BranchName & "|"
    If param3 = -1 then s = s & "ALL" else s = TerritoryName
    Return s
    End Function
    Regards, RSingh

  • How convert date/time from xml in xdp(Designer)?

    Hi, i want to convert date/time format from xml in Designer, date/time value in xml is NOT in common format YYYY-MM-DD (if is in a common format i can do this with pattern)
    I have a "DateTime" Field in Xdp can get from Xml date and time:
    In XML <DateTime>DD-MM-YYYY</DateTime> i want to convert in XDP in DateTime Field in "DD-April-YYYY"
    Can i do this?

    You can do this way..
    Bind the date field to your XML tag.
    Set the display pattern for the date field.
    In the initialize event of the date field place the following code.
    Set JavaScript as language.
    var dtStr = this.rawValue;
    var pos1=dtStr.indexOf("-");
    var pos2=dtStr.indexOf("-",pos1+1);
    var strMonth=dtStr.substring(0,pos1);
    var strDay=dtStr.substring(pos1+1,pos2);
    var strYear=dtStr.substring(pos2+1);
    //Assign the formatted value to the Date field.
    this.rawValue = strYear + "-" + strMonth + "-" + strDay;
    Thanks
    Srini

Maybe you are looking for