Operations on Text File - Encrypt, Decrypt, Password Protected

Dear Experts,
My requirement is to upload a text file  and do some operations on it and then encrypt the content in it ans save it on application server with password protected. Later i want to decrypt it.
Please help me for the following:
How to encyypt and decrypt the text file using standard encryption alogrithms like DES, MD5, RSA? Are there any standand function modules for both encryption and decryption which accepts a user defined public key?
How to download a password protected text file?
Thanks in advance.

CALL FUNCTION 'Z_CRYPT_FILE'
        EXPORTING
          SOURCE_PATH         = WS_PATH
          SOURCE_FILE         = WS_OLDFILE
          DESTINATION_PATH    = WS_NEW_PATH
          DESTINATION_FILE    = WS_NEWFILE
          SWITCH              = 'E'
          KEY                 = ZUSER_PW
          KEEP_SOURCE_FILE    = ' '
        EXCEPTIONS
          INVALID_SWITCH      = 1
          SOURCE_FILE_NOTFOUND = 2
          DIDNT_WORK          = 3.
FUNCTION MODULE Z_CRYPT_FILE 
DATA: CINPUT(300) TYPE C.
DATA: BEGIN OF LIST OCCURS 0,
        DATA(238) TYPE C,
        DELIMITER(04) TYPE C,
        FILE(12) TYPE C,
      END OF LIST.
DATA: SOURCE TYPE ZCHAR200.
DATA: DESTINATION TYPE ZCHAR200.
DATA: ZINDX TYPE I.
DATA: msg(100).
IF SWITCH = 'E'.
   IF FILETYPE = 'T'.
      OPEN DATASET SOURCE IN TEXT MODE FOR INPUT ENCODING DEFAULT
         message msg.
   ELSE.
      OPEN DATASET SOURCE IN BINARY MODE FOR INPUT message msg.
   ENDIF.
   IF SY-SUBRC <> 0.
      RAISE SOURCE_FILE_NOTFOUND.
   ENDIF.
   CLOSE DATASET SOURCE.
   CLEAR CINPUT.
   CONCATENATE '/usr/local/bin/gpg -sev -r'
    KEY
    '-o'
    DESTINATION
    SOURCE
   INTO CINPUT SEPARATED BY SPACE.
   CONCATENATE CINPUT '2>&1' INTO CINPUT SEPARATED BY ' '.
   CALL 'SYSTEM' ID 'COMMAND' FIELD CINPUT ID 'TAB' FIELD
                              LIST-SYS.
   IF FILETYPE = 'T'.  
      OPEN DATASET DESTINATION IN TEXT MODE FOR INPUT ENCODING DEFAULT
         message msg.
   ELSE.
      OPEN DATASET DESTINATION IN BINARY MODE FOR INPUT message msg.
   ENDIF.
   IF SY-SUBRC = 0.
      CLOSE DATASET DESTINATION.
      IF keep_source_file <> 'X'.
         CLEAR CINPUT.
         CONCATENATE 'rm' SOURCE INTO CINPUT
         SEPARATED BY SPACE.
         CALL 'SYSTEM' ID 'COMMAND' FIELD CINPUT ID 'TAB' FIELD
                        LIST-SYS.
      ENDIF.
   ELSE.
    write: 'Encryption error  on command: ',
       cinput.
    skip 1.
     loop at list.
        write: / LIST.
       endloop.
      RAISE DIDNT_WORK.
   ENDIF.
   IF FILETYPE = 'T'.  
      OPEN DATASET SOURCE IN TEXT MODE FOR INPUT ENCODING DEFAULT.
   ELSE.
      OPEN DATASET SOURCE IN BINARY MODE FOR INPUT.
   ENDIF.
   IF SY-SUBRC <> 0.
      RAISE SOURCE_FILE_NOTFOUND.
   ENDIF.
   CLOSE DATASET SOURCE.
   CLEAR CINPUT.
   CONCATENATE '/usr/local/bin/gpg -o'
    DESTINATION
    SOURCE
   INTO CINPUT SEPARATED BY SPACE.
   CONCATENATE CINPUT '2>&1' INTO CINPUT SEPARATED BY ' '.
   CALL 'SYSTEM' ID 'COMMAND' FIELD CINPUT ID 'TAB' FIELD
                              LIST-SYS.
  REFRESH LIST.
  CLEAR LIST.
   IF FILETYPE = 'T'. 
      OPEN DATASET DESTINATION IN TEXT MODE FOR INPUT ENCODING DEFAULT.
   ELSE.
      OPEN DATASET DESTINATION IN BINARY MODE FOR INPUT.
   ENDIF.
   IF SY-SUBRC = 0.
      CLOSE DATASET DESTINATION.
   ELSE.
*list output if error
      loop at list.
        write: / LIST.
       endloop.
      RAISE DIDNT_WORK.
   ENDIF.
ENDIF.

Similar Messages

  • Encrypt / Decrypt password

    Hi
    I'm new in Java and I need to create a function to encrypt / decrypt passwords using the Blowfish algorithm. I know how to create a key, but I don't know how to recover it to decrypt the password.
    Another question, Is it possible to use public/private keys in this case???.
    Can you give some links or examples please???
    Regards
    J.C.

    This is typically done either one of two ways:
    1) PBE based encryption. This uses a password or pass phrase to derive
    a key to use with a symmetric algorithm.
    2) Asymmetric using something like RSA. Typically RSA is used to wrap
    the actual symmetric key used to do the encryption but for very short
    plaintext it can be used directly on the plaintext. Passwords are a
    good example of short plaintext.
    Obviously symmetric encryption is a great deal faster than asymmetric
    encryption. So if your plaintext was large you would want to use
    symmetric. Also Asymmetric encryption is length dependant. AKA if your
    public key's modulus is 1024 bits then you could encrypt any plaintext
    that was 121 bytes or shorter.
    PBE takes a salt (a random byte array) and an iteration count and
    hashes a passphrase with the salt iteration number of times to generate
    a key that can be reproduced over and over again and used with a
    symmetric algorithm. The issue here is that your salt/ic either need
    to be hard coded and reused or the values for any single encryption
    need to be saved along with the ciphertext. Using the same ic/salt for
    a large number of plaintext to ciphertext operations can lead to a
    weakening of the pass phrase (aka the key) and aids a cryptoanalyst in
    breaking the code. Although it is still difficult it becomes easier
    with each successive encryption.
    Its upto you which route you take but you should note that private keys
    used in asymmetric encryption use PBE to keep them private anyway so in
    a sense if you use asymmetric encryption you are really using both
    asymmetric encryption and PBE...

  • Deploying of an .ear file which is password protected

    When we try to deploy a password protected .ear file,through the Weblogic
    Console,the deployment fails.
    java.io.IOException: invalid CEN header (encrypted entry) with :
    D:\SAMPLEAPP.ear at java.util.zip.ZipFile.open(Native Method) at
    java.util.zip.ZipFile.<init>(ZipFile.java:114) at
    java.util.jar.JarFile.<init>(JarFile.java:133) at
    java.util.jar.JarFile.<init>(JarFile.java:97) at
    weblogic.utils.jars.JarFileDelegate.<init>(JarFileDelegate.java:32) at
    weblogic.utils.jars.VirtualJarFactory.createVirtualJar(VirtualJarFactory.java
    :24) at
    weblogic.application.compiler.SCACompilerFactory.createMerger(SCACompilerFact
    ory.java:37) at
    weblogic.application.compiler.flow.AppMergerFlow.createMerger(AppMergerFlow.j
    ava:68) at
    weblogic.application.compiler.flow.AppMergerFlow.mergeInput(AppMergerFlow.jav
    a:85) at
    weblogic.application.compiler.flow.AppMergerFlow.compile(AppMergerFlow.java:4
    1) at
    weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java
    :69) at
    weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.ja
    va:41) at
    weblogic.application.compiler.FlowDriver.nextState(FlowDriver.java:36) at
    weblogic.application.compiler.FlowDriver$CompilerFlowDriver.compile(FlowDrive
    r.java:96) at
    weblogic.application.compiler.AppMerge.runBody(AppMerge.java:157) at
    weblogic.utils.compiler.Tool.run(Tool.java:158) at
    weblogic.utils.compiler.Tool.run(Tool.java:115) at
    weblogic.application.compiler.AppMerge.merge(AppMerge.java:169) at
    weblogic.deploy.api.internal.utils.AppMerger.merge(AppMerger.java:88) at
    weblogic.deploy.api.internal.utils.AppMerger.getMergedApp(AppMerger.java:63)
    at
    weblogic.deploy.api.model.internal.WebLogicDeployableObjectFactoryImpl.create
    DeployableObject(WebLogicDeployableObjectFactoryImpl.java:181) at
    weblogic.deploy.api.model.internal.WebLogicDeployableObjectFactoryImpl.create
    LazyDeployableObject(WebLogicDeployableObjectFactoryImpl.java:156) at
    weblogic.deploy.api.tools.SessionHelper.inspect(SessionHelper.java:661) at
    com.bea.console.actions.app.install.Flow$2.execute(Flow.java:469) at
    com.bea.console.utils.DeploymentUtils.runDeploymentAction(DeploymentUtils.jav
    a:5000) at
    com.bea.console.actions.app.install.Flow.appSelected(Flow.java:467) at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
    java:25) at java.lang.reflect.Method.invoke(Method.java:597)
    I would like to know the steps how to deploy a ear file which is password protected. The ear has one jar file & a war file.
    Awaiting suggestions
    Karthik

    Hi Karthik,
    there is one enhancement request were opened for this issue.
    BUG 12605295.
    you need to wait till this got updated.
    Regards,
    Kal

  • SAP version 4.7  Email pdf file that is password protected.

    Hi Gurus,
    We have a requirement:
      Email pdf file that is password protected.
      Once the user receives the email,  clicks on the attached pdf file,
         it should ask the password.  Note that Password value should come from SAP.
    What we have done is get the spool number and by using function module CONVERT_ABAPSPOOLJOB_2_PDF, it converts the spool document to pdf.
    On this function module, there are no parameters to make pdf as password protected and
      also include the password.  This is the problem.
    Question:
       (a) Is there a way to make pdf password protected that will be emailed?
            What function modules, etc to be used?  (sample coding if available)
       (b) Somebody mentioned the that Adobe LiveCycle Policy Server should be installed together with SAP.
            If this is installed, how then would be the abap coding be in order to make the pdf password
                protected?
            How is the new policy server gonna be linked to SAP and how do the abap coding gonna be?
               (sample abap coding if available)
    Thanks.
    Raymund

    hi,
    First save the file somewhere... LINK:[SITE|http://www.sapfans.com/forums/viewtopic.php?f=13&t=326228]
    In the site i send above you need to change it do receive parameters ou use always the same name...compile and then use the function 'WS_EXECUTE' - watch it in LINK: [SITE|http://www.sap-img.com/abap/ws-execute-to-call-external-program.htm]
    and then..you just have to download it again into an ITAB and send it by mail... LINK:[SITE|How to pass pdf data to ABAP itab;
    Hope it helps..

  • HT4088 Will numbers open an excel file that is password protected? Xlsx latest ms excel?

    Will numbers open an excel file that is password protected? Xlsx latest ms excel?

    No. None of the iWork apps on any platform will open a password-protected Office file. You have to remove the password in Office first.

  • Share Excel File that is password protected

    Hello all
    I have published a workbook in our shared area at work. It's massive and also has another workbook linked to it.
    Both are password protected so are only available for viewing. But tons of people need to see them particularly the source file which is no problem because they can't change anything so can choose 'read only'.
    However the problem is when I need to go in there to make a couple of alteration, I have to wait until they close it or of course as is typical, they will leave their desk and forget to close it!!
    I haven't used the sharing workbook option although I've tried it and shown one of our departments to use it basically.
    I was wondering if this would be possible on a file that is password protected and is locked on every sheet.
    That way I can just go in when I need to even if someone's in there.
    This is an extremely important file that
    can not go wrong.  (I do have a backup)
    What are your views on this option and what is the best way to go about it?
    Thanks

    Hi,
    Would you like to tell me which Excel version are you using? According to your description, I recommend we try the two methods:
    Method 1:
    Excel has a feature "Protected the sheet", we can assign the different password to each sheet.
    For more detail information, please refer to the following link:
    http://office.microsoft.com/en-gb/excel-help/password-protect-worksheet-or-workbook-elements-HP010078580.aspx
    Method 2:
    Share the Excel workbook, and assign the edit range/permission to users. We can allow specific users to edit ranges in Excel. Here is the steps:
    Click 'Review', 'Allow Users to Edit Ranges','New'. In 'Title', enter the name. In 'Refers to cells', enter an equal sign (=) and enter the reference. In 'Range password', enter password. Click 'Permissions'. Click 'Add'. Enter the name. Click 'Protect Sheet',
    enter password. Click 'OK'.
    https://askdrexel.drexel.edu/app/answers/detail/a_id/2498/~/how-to%3A-allow-specific-users-to-edit-ranges-in-excel-2007.
    http://office.microsoft.com/en-us/excel-help/use-a-shared-workbook-to-collaborate-HP010096833.aspx
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • How to ZIP a PDF File with a Password Protection

    Hi,
    i've a pdf file with created smartforms and i want to assign a password to that pdf file but the SAP doesn't let doing that protection. So i want to create a zip file with a password protection for PDF file.
    How can i create a zip file with a password protection? Can somebody help me please?
    Thanks.

    Hello,
    Check this links
    Take a look to the class CL_ABAP_GZIP
    open (top-)zip-archive
    CALL METHOD lo_zip->load
        EXPORTING
          zip             = lv_zip_file_head
        EXCEPTIONS
          zip_parse_error = 1
          OTHERS          = 2.
    create sub-zip-archives which contain the files you would assign to a folder
    add sub-zip-archive to top-zip-archive
    CALL METHOD lo_zip->add
         EXPORTING
            name    = lv_zip_filename
            content = lv_zip_file.
    save zip-archive
    CALL METHOD lo_zip->save
        RECEIVING
          zip = ev_zip_file.
    ABAP Development
    How to ZIP a PDF file email attachment
    Re: How to ZIP a PDF file email attachment

  • Encrypted or Password Protected Text Files?

    I don't suspect there's anyway to protect text files that I load on to my iPod, is there? That would be a very cool feature to add in the future, even if it's using the "safe combination" technique used to screen lock.

    I don't suspect there's anyway to protect text files
    that I load on to my iPod, is there?
    I've sucessfully done this already. The files remain perfectly readable but you won't ever understand them again (but that's a small price to pay for the peace of mind you get).
    Looks like the screenlock's your only answer!

  • Download File thru Text file and add password to protect text file

    Hello ABAPers,
    I have a problem regarding downloading of file in text file with password...meaning I need to protect with password the text file i created without human intervention...is it possible to ABAP? im using FM GUI_DOwnload and save it to text file.
    Please Help...Will reward points ...
    Thanks in advance.
    aVaDuDz

    Hi
    You could use OLE to integrate SAP with Excel - create files, execute macros etc. (search for DOI on SAP help), but this will only work on the presentation server, so you couldn't run it as a service in background. I suppose your e-mails are sent through the internet, hence the requirement for encryption -- or maybe your client doesn't trust its network people! For this you really should use strong encryption -- anything less, you might as well send plain text. One solution to this would be to send the email down a VPDN -- this would encrypt all traffic between source and destination. Another would be to encrypt the file just before it is attached to the email. This could be done within ABAP, but perhaps a third party public key encryptor would be better placed. This could be invoked via a system command call, or as an RFC. A third solution would be to have your mail server handle the encryption.
    Heres the link for the above explaination
    http://searchsap.techtarget.com/ateQuestionNResponse/0,289625,sid21_gci1037837,00.html?track=sap805s
    One more link
    <a href=" http://www.telfordpct.nhs.uk/healthcare_professionals/SAP/creating_sap_documents_in_word_copy(1).htm ">http://www.telfordpct.nhs.uk/healthcare_professionals/SAP/creating_sap_documents_in_word_copy(1).htm</a>
    Regards
    Raj
    Message was edited by:
            Rajasekhar Dinavahi

  • Why can't I save my password protected file in a password protected folder?

    I've just encrypted my folder which contains password protected files. I've attempted to save a new password protected file (Word document) but have had to save it to my desktop because when I try to save the file to the folder I receive a message: "Word cannot save or create this file. The disk may be full [which it is not] or write-protected [which it is]". Sooooooo. Does this mean I can only password protect the folder and not the files? Which is really annoying because I really do need the two levels of security. Please can someone help?

    File Vault is not in Disk Utility.  It is in System Preferences/Security/FileVault.

  • Error running SSIS package to do with encrypting/decrypting password. Help needed.

    Getting this error. Can anyone shed some light? This is the first promote since 2009. Protection level of the package is 'EncryptSensitiveWithPassword' I'm new at SSIS so don't assume I know anything.
    10/30/2014 16:11:06,HPAddress_Export,Error,0,SSQLTST01\SSQLTST02,HPAddress_Export,(Job outcome),,The job failed. 
    The Job was invoked by User AHCCCS\Administrator.  The last step to run was step 1 (Step 1).,00:00:02,0,0,,,,0
    10/30/2014 16:11:06,HPAddress_Export,Error,1,SSQLTST01\SSQLTST02,HPAddress_Export,Step 1,,Executed as user: AHCCCS\svcssqltst01. ....00.5324.00 for 32-bit 
    Copyright (C) Microsoft Corp 1984-2005. All rights reserved.   
    Started:  4:11:06 PM  Error: 2014-10-30 16:11:07.05    
    Code: 0xC001405F     Source:      
    Description: Failed to decrypt an encrypted XML node because the password was not specified or not correct. Package load will attempt to continue without the encrypted information. 
    End Error  Error: 2014-10-30 16:11:07.37    
    Code: 0xC001405F     Source:      
    Description: Failed to decrypt an encrypted XML node because the password was not specified or not correct. Package load will attempt to continue without the encrypted information. 
    End Error  Error: 2014-10-30 16:11:07.79    
    Code: 0xC0202009     Source: HPAddress_ExportPackage Connection manager "SQL.HealthPlanAddressChanges.hpac"    
    Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E4D. 
    An OLE DB record is available.  Source: "Micros... 
    The package execution fa...  The step failed.,00:00:02,0,0,,,,0

    Hi,
    From the error message “Failed to decrypt an encrypted XML node because the password was not specified or not correct. Package load will attempt to continue without the encrypted information.“, it seems that the error is caused by the password to decrypt
    an encrypted XML node was not specified or incorrect.
    Besides, the EncryptSensitiveWithPassword Protection level means user should use a password to encrypt only the values of sensitive properties in the package. To open the package in SSIS Designer, the user must provide the package password. If the password
    is not provided, the package opens without the sensitive data and the current user must provide new values for sensitive data. If the user tries to execute the package without providing the password, package execution fails.
    So in order to resolve this issue, we should provide the password when executing the package. When you execute a package with this setting using DTEXEC, you can specify the password on the command line using the /Decrypt password command line argument.
    Reference:
    Access Control for Sensitive Data in Packages
    Securing Your SSIS Packages Using Package Protection Level
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Please Help!!!  Encrypt/Decrypt Password

    i'm a newbie to Cryptography...and i know that this question have been asked MILLIONS of time...but i'm going to ask it again. i searched through the forum, and i didn't find anything useful...but:
    i want to write a program to encrypt the password i type in the JPasswordField...save it out to a Properties file...when i'm trying to authentication, get the password...decrypt the password...and authentication.
    i pretty much have the JPasswordField and Properties file done...i just need the encryption and decryption left.
    can someone please help??? please post example code...please don't suggest hashcode!!!
    sin sai

    Try this, found at:
    [ http://java.ittoolbox.com/documents/document.asp?i=1676 ]
    You can convert your password to MD5 format as follows:
    import java.security.*;
    import java.lang.*;
    public class PasswordEncrypt {
    * Constructor for the PasswordEncrypt object
    public PasswordEncrypt() { }
    * This is the method which converts the any string value to MD5
    format.
    *@param str password
    *@return encrypted password in MD5
    public String encrypt(String str) {
    StringBuffer retString = new StringBuffer();
    try {
    MessageDigest alg = MessageDigest.getInstance("MD5", "SUN");
    String myVar = str;
    byte bs[] = myVar.getBytes();
    byte digest[] = alg.digest(bs);
    for (int i = 0; i < digest.length; ++i) {
    retString.append(Integer.toHexString(0x0100 + (digest[i] &
    0x00FF)).substring(1));
    } catch (Exception e) {
    System.out.println("there appears to have been an error " + e);
    return retString.toString();
    ---

  • Locking Files or Folders -- Password protected access?

    I know how to simply lock a folder or file so it can't be altered or deleted, by selecting 'Locked' in the file or folder's information box. But is it possible to lock a folder or file so it requires a password to be accessed, without having to use a third-party program? A simple OS X password protected locking feature.
    17" iMac G4, 1GHz PowerPC, 768mb RAM Mac OS X (10.4.10)

    Hi
    The only built-in way you can do this is by creating an encrypted disk image from the folder using Disk Utiility. When you create the image, make sure you select type "encrypted", and when you first enter the password, make sure not to select "save password in keychain". And test opening the image with the password before you delete the original folder, just in case.
    Matt

  • OLE2 Excel File Save as password protected

    Hi All,
    I would like to save an Excel File as Password protected.
    This File is created by OLE2.
    How can I do this?
    This is the Coding, how I save the File-->
    CALL METHOD OF ls_wbook 'SaveAs' EXPORTING #1  = p_file.
    Thanks for the Answers...
    Bye
    Besi

    Hello Besi,
    The following code should work. Try it out.
    CALL METHOD OF document 'Protect' EXPORTING
                             #1 = 2
                             #2 = -1
                             #3 = 'password'.
    CALL METHOD OF documents 'Save'.
    Here 'document' is the 'ActiveDocument' object.
    How to get the 'document'  object:
        CREATE OBJECT worddoc 'Word.Document'.
        GET PROPERTY OF worddoc 'Application' = wordapp.
    GET PROPERTY OF wordapp 'ActiveDocument' = document.
    Regards,
    Jitendar

  • Why is Get File Type.vi password protected

    Hi...  We have a code that was developed in LabVIEW 8.6...  We have a need to attempt to save this code all the way back to version 7.1...  I saved it back from 8.6 --> 8.5 --> 8.2.1 --> 8.0 with no issues...  But when I then try to save it back from 8.0 to 7.1 I encounter one LabVIEW 8 vi that has no equivalent functionality in 7.1...  And that one vi is
    C:\Program Files\National Instruments\LabVIEW 8.x\vi.lib\Utility\lvfile.llb\Get File Type.vi
    When I look at that vi in 8.x, to endeavor to see if I can replace its functionality by writing some code in 7.1, I find that the Get File Type.vi is password protected...  More out of curiousity than anything, why is that code password protected???  I wasn't aware that any of the standard purchased LabVIEW code came password protected...  Can anyone tell me why that is???  thanks...  bob..
    Solved!
    Go to Solution.

    That VI is using an internal callback into LabVIEW (i.e. non G-based code) to determine the type of the file.  I'm guessing the callback doesn't exist in 7.1, so you would need to write your own G-based implementation for getting the type of a file  in the 7.1 case.  The simplest solution would be to work with the extensions of the files...not perfect, but probably close enough assuming your files are well-named.  Also, the following VI can give you a bit more information about LabVIEW-specific files (independent of extension):
    LabVIEW 7.1\vi.lib\Utility\libraryn.llb\Librarian Get Info.vi
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

Maybe you are looking for