Base64Encode ==

Hello.
Just a quick question on Base64Encoding and MD5.
I'm hashing passwords, then encoding to stuff into DB. All of my encoded data ends in '=='
example:
LN2vQZp6JLpt+b3xFInn2A==
Can anyone tell me why they all end in '==' ?
Thanks in advance.
Vic.

I have a question I am currently using MD5 to hash passwords and Base64Encoder to encode the string before inserting it in the database. I have a probelm though, I used UTF-8 to make the password platform independent for both Java on Windows and Java on Unix. However, it is not working...when the user creates a user on the Unix platform and tries to log in with that userid/password which was hashed/encoded on Unix platform, in a Windows platform, the password is different from what was stored on the Unix platform and what is passed in from the user hashed and encoded on the Windows platform. Do you have a solution for this. Here is my code below. Please HELP! Thanks so much!
public String doIt(String test) {
try {
sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
secret = new String(encrypt(test));
//System.out.println("the encrypted result : " + secret);
encoded=encoder.encode(secret.getBytes());
System.out.print("Here is the encoded string in LIMDBO" + encoded);
boolean ok = true;
//String s = "";
} catch (Exception e) {
e.printStackTrace();
return encoded;
static byte[] encrypt(String x) throws Exception {
java.security.MessageDigest d = null; //comment
d = java.security.MessageDigest.getInstance("MD5"); //comment when released
// d = java.security.MessageDigest.getInstance("SHA"); uncomment when released
d.reset();
d.update(x.getBytes("UTF-8"));
return d.digest();
}

Similar Messages

  • Byte array to base64encoder problem, cannot encode a 7.7 MB file

    hey guys, so ive been trying to use the base64encoder to encode a bytearray which is then sent thru a webservice to the server to be decoded.
    and as the subject of this post suggests, i have been having problems encoding a big file,
    forexample i tried to upload/convert a 84KB image and it worked just fine... the trace of the string ended with a "==" which i believe means that the conversion is complete...
    but when i try to upload a 7.7MB image, it is, i guess, crashing... i dont see any "==" in the string... so i guess its not working... i was wondering if there is any any type of file size limit or soemthign for the encoding...
    the code i have is
    import flash.events.Event;
    import flash.net.FileFilter;
    import flash.net.FileReference;
    import flash.utils.ByteArray;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.utils.Base64Encoder;
    import services.images.ImageData;
    import services.images.Images;
    import services.images.ReturnMessage;
    // ActionScript file
        public var fileRef:FileReference = new FileReference();
        public var imgCollection:ArrayCollection = new ArrayCollection();
        public var imgService:Images = new Images();
        public var imageData:ImageData = new ImageData();
        public var returnMsg:ReturnMessage = new ReturnMessage();
        public function onBrowseButtonClicked(event:MouseEvent):void{
            var arr:Array = [];
            arr.push(new FileFilter("Images", ".gif;*.jepg;*.jpg;*.png"));
            fileRef.browse(arr);
            fileRef.addEventListener(Event.SELECT, fileRef_select);
            fileRef.addEventListener(Event.COMPLETE, fileRef_complete);
        public function fileRef_select(event:Event):void{
            fileRef.load();
        public function fileRef_complete(event:Event):void{
            img.source = fileRef.data;
            var fileByteArr:ByteArray = fileRef.data;
            var b64En:Base64Encoder = new Base64Encoder();
            b64En.encodeBytes(fileByteArr);                                                  //<----------------------------------------------------------
            var str:String = b64En.flush();                                                        //<----------------------------------------------------------
            trace(str.length);
            b64En.reset();
            trace("------------------------------------      " + str + "     -----------------------------");
            imageData.Base64EncodedImage = str;
            imageData.FileName = "nameofstring";
            imgService.UploadImage(imageData);
           imgService.addEventListener(FaultEvent.FAULT, servFault);
           imgService.addEventListener(ResultEvent.RESULT, imgServSuccess);
        public function imgServSuccess(event:ResultEvent):void{
            Alert.show("i am in the result");
            returnMsg = event.result as ReturnMessage;
            var resultStr:String = event.result as String;
            Alert.show(resultStr);
            if(returnMsg.ThereWasAnError){
                trace(returnMsg.ErrorMessages.getItemAt(0).toString());
        public function servFault(event:FaultEvent):void{
            Alert.show("2 " + event.fault.message);
            Alert.show("3 " + event.fault.faultCode);
    any help will be greatly appretiated!! thanks in advace!

    yeah i did actually... except i think i changed a LOT of code since i last posted this article...
    so i dont remember where this code is exactly... lol
    i have the following code now...
    hope this helps
    i use a a lot of webservices... so there is some of that code included in there aswell...
    * This file will do the file upload. It has been suggested to me multiple times, that using a queueing system for
    * file upload is not a good idea. Instead I declared a counter and used the final function to fire the next item
    * in the array. this also makes canceling a routine easier.
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.net.FileReference;
    import flash.net.FileReferenceList;
    import flash.utils.ByteArray;
    import mx.collections.ArrayCollection;
    import mx.controls.*;
    import mx.managers.*;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.utils.Base64Decoder;
    import mx.utils.Base64Encoder;
    import services.images.Images;
    import valueObjects.*;
        public var t:Number = 0;
        public var fileRef:FileReferenceList = new FileReferenceList();
        public var listCacheFiles:Array = new Array();
        [Bindable] public var fileListArr:Array = new Array();
        [Bindable] public var fileNames:ArrayCollection = new ArrayCollection();
        [Bindable] public var arrUploadFiles:Array = new Array();
        public var file:FileReference;
        public var _numCurrentUpload:Number = 0;
        public var imageData:valueObjects.ImageData;
        public var imageService:Images = new Images();
        public var saveImages:Images;
        public var returnMsg:ReturnMessage = new ReturnMessage();
        public var dataToSave:ImageData;
        public var myCounter:int = 0;
        public var numPerc:Number;
        /*vars to possible delete*/
        public var fileListx:ArrayCollection;
         * Initiates the browse, when files are selected the selectionHandler function is called
        public function initiateBrowse():void{
            var filter:Array = [];
            filter.push(new FileFilter("Images", ".gif;*.jepg;*.jpg;*.png"));
            fileRef.addEventListener(Event.SELECT, selectionHandler);
            fileRef.browse(filter);
         * selection handler takes the selected files and puts them in 2 different arrays
         * fileListArr contains all the file information like the image itself and the name and everything
         * fileNames contains the information essential to populate the datagrid in the cropper.mxml
        public function selectionHandler(event:Event):void{
            //trace("selection Handler ->>");
            fileRef.removeEventListener(Event.SELECT, selectionHandler);
            var numSelected:int = event.target.fileList.length;
            var fileList:Array = event.target.fileList;
            fileListx = new ArrayCollection();
            fileListx = event.target.fileList as ArrayCollection;
            //var oldListLength:Number = fileListArr.length;
            for each(var item:Object in fileList){
                fileListArr.push(item);
                fileNames.addItem({
                    num: fileNames.length + 1,
                    name: item.name,
                    size: formatFileSize(item.size),
                    status: "",
                    itemDetails: item
            var newListLength:Number = fileListArr.length;
            if(myCounter > 0)
                loopList(myCounter);
            else
                loopList(0);
         * this function starts one, new filereference for each files in the array
        public function loopList(value:int):void{
            //trace("looplist -->");
            if(value < fileListArr.length){
                _numCurrentUpload = value;       
                file = new FileReference();
                file = FileReference(fileListArr[value]);;
                file.addEventListener(Event.COMPLETE, loadImage);
                file.addEventListener(ProgressEvent.PROGRESS, fileProgress);
                file.load();
         * This function will convert the byte array into a string, and then it sends it to the server.
        public function loadImage(event:Event):void{
            trace("loadImage -->");
            file.removeEventListener(Event.COMPLETE, loadImage);
                myCounter += 1;
                var fileByteArr:ByteArray = event.target.data;
                var b64En:Base64Encoder = new Base64Encoder();
                b64En.encodeBytes(fileByteArr);
                var str:String = b64En.flush();
                imageData = new ImageData();
                imageData.Base64EncodedImage = str;
                imageData.FileName = event.target.name;
                trace("sending -->>  " + imageData.FileName);
                updateStatus("Sending to server");
                imageService.addEventListener(ResultEvent.RESULT, imgServSuccess);
                imageService.UploadImage(imageData);
                b64En.reset();
         * This function will decode the information recieved back from the server.
        public function imgServSuccess(event:ResultEvent):void{
            trace("imgServSuccess -->");
            imageService.removeEventListener(ResultEvent.RESULT, imgServSuccess);
            var returnedImageId:ArrayCollection = new ArrayCollection();
            returnMsg = event.result as ReturnMessage;
            var returnedData:Object = event.result.Images;
            var imgD:ImageData = new ImageData();
            if(returnMsg.ThereWasAnError){
                trace(returnMsg.ErrorMessages.getItemAt(0).toString());
            else{
                for each(var imgData:ImageData in returnedData){
                    var decoded:Base64Decoder = new Base64Decoder();
                    decoded.decode(imgData.Base64EncodedImage);
                    var byteArr:ByteArray = decoded.toByteArray();
                    //img.source = byteArr;
                dataToSave = new ImageData();
                dataToSave = returnedData[0];
                listCacheFiles.push(dataToSave);
                updateStatus("Item in Cache");
                //uploadDetails.visible = true;
                loopList(myCounter);
        public var win:itemDetails;
        public function itemClicking(event:Event):void{
            var fileName:String = event.currentTarget.dataProvider[0].name;
            for(var i:Number = 0; i < listCacheFiles.length; i++){
            //var temp:ImageData = event.target as ImageData;
            win = null;
            win = itemDetails(PopUpManager.createPopUp(this, itemDetails, true));
            win.title = "Enter Details";
            PopUpManager.centerPopUp(win);
            win["save"].addEventListener("click", popupClosed);
        public function popupClosed(event:Event):void{
            var returnedData:ImageData = new ImageData;
            returnedData = win.dataToSave;
            saveImgAndData(returnedData);
        public function saveImgAndData(data:ImageData):void{
            saveImages = new Images;
            saveImages.showBusyCursor = true;
            saveImages.addEventListener(ResultEvent.RESULT, savedSuccess);
            saveImages.addEventListener(FaultEvent.FAULT, faultFunc);
            saveImages.SaveUploadedImageInformation(data);
        public function faultFunc(event:FaultEvent):void{
            Alert.show(event.fault.message);
            Alert.show(event.fault.faultString);
        public function savedSuccess(event:ResultEvent):void{
            //trace("savedSuccess -->");
            var retMsg:Object = event.result.Images;
            //trace("saving -->> " + retMsg[0].FileName);
            updateStatus("Completed");
            //loopList(myCounter);
        private function formatFileSize(numSize:Number):String {
            var strReturn:String;
            numSize = Number(numSize / 1024);
            strReturn = String(numSize.toFixed(1) + " KB");
            if (numSize > 1024) {
                numSize = numSize / 1024;
                strReturn = String(numSize.toFixed(1) + " MB");
                if (numSize > 1024) {
                    numSize = numSize / 1024;
                    strReturn = String(numSize.toFixed(1) + " GB");
            return strReturn;
        public function removeFiles():void{
            var arrSelected:Array = displayFilesList.selectedIndices;
            if(arrSelected.length >= 1){
                for(var i:Number = 0; i < arrSelected.length; i++){
                    fileNames[Number(arrSelected[i])] = null;
                var idx:int = 1;
                for(var j:Number = 0; j < fileNames.length; j++){
                    if(fileNames[j] == null){
                        fileNames.removeItemAt(j);
                        j--;
                    }else{
                        fileNames[j].num = idx++;
                if(fileNames.length > 0)
                    displayFilesList.selectedIndex = 0;
                else
                    displayFilesList.selectedIndex = -1;
                _numCurrentUpload--;
                updateProgBar();
        private function updateStatus(status:String, index:Number = -1):void{
            index = _numCurrentUpload;
            fileNames[index].status = status;
            displayFilesList.invalidateList();
        public function fileProgress(event:ProgressEvent):void{
            //trace("fileProgress -->");
            var numPerc:Number = Math.round((Number(event.bytesLoaded) / Number(event.bytesTotal)) * 100);
            updateStatus("Uploading: " + numPerc.toString() + "%");
            updateProgBar(numPerc);
            var evt:ProgressEvent = new ProgressEvent("uploadProgress", false, false, event.bytesLoaded, event.bytesTotal);
            dispatchEvent(evt);
        public function updateProgBar(numPerc:Number = 0):void{
            //trace("updateProgBar -->");
            var strLabel:String = (_numCurrentUpload + 1) + "/" + fileNames.length;
            progBar.label = strLabel;
            progBar.setProgress(_numCurrentUpload + numPerc / 100, fileNames.length);
            progBar.validateNow();

  • Display Base64Encoder string(barcode) as image in jsp/email

    Hi,
    I am trying to display the barcode image in jsp from the Base64Encoder encoded string.
    Earlier i tried to set the output stream of barcode image in the response of the HttpServlet. However, this is not working when i view in the mobile device android/iphone.
    Now when i use this Base64Encoder, the string which i am passing to the email template(jsp page), i cant able to view the image when i view in the email(outlook).
    But when open this outlook content(.mht) in browser(IE 8), able to see the image. Also when forward this email to the android/iphone mobile device, able to see the image.
    The barcode image is not displayed only when i open the email directly in the outlook/browser.
    Please help me to resolve this issue.

    Hi Gopi,
    Thanks for your reply.
    when i open the email in outlook, i am getting 'If there are problems with how this message is displayed, click here to view in a web browser'. So when i view in browser(IE) on clikc of this link, the email opened from the temporary internet files(AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\54AMMRVF\email (4).mht)
    Here i am able to see the image.
    Suppose if i forward this email to my gmail and opening in a browser, this time i cant see the image. i am getting only the blank space there.

  • Import sun.misc.BASE64Encoder;

    Hi,
    Can we use "import sun.misc.BASE64Encoder;" library in java mapping?
    Thanks,
    Best Regards.

    Yes,you can.
    Check out the following blog for an example : http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417400)ID1015865250DB11252644827406985331End?blog=/pub/wlg/9793%3Fpage%3Dlast%26x-order%3Ddate
    Thanks,
    Pooja Pandey

  • Where to find sun.misc.BASE64Encoder

    Hi!
    I'm not sure if this is the right forum but...
    I need to encode a string in Base64 but I don't know how.
    I found people using the class sun.misc.BASE64Encoder but I can�t find it.
    I suppose it is part of a package that is downloadable (i hope at least) but I don't know where to search.
    I don't need an automatic encoder really. I just want to encode a particular string. Is there another one-time-solution?
    Please help
    Kind regards
    /Stefan F�gersten, InfoGrator

    There are a number of free open source Base64 encoders. As a rule, you should not rely on classes in 'com.sun'. It's somewhat unfortunate that they didn't provide a Base64 encoder/decoder in the stock library, it's quite a common request.
    http://www.google.com/search?q=Java+Base64+Encode
    Good luck,
    -Derek

  • Sun.misc.BASE64Encoder and JDK 1.4.1 for Unix

    I apologize for asking what seems like such a basic question in this forum, but my search for help with this issue has been unsuccessful so far.
    I developed a Java application under JDK 1.3.0 for Windows 9x/NT4 which uses sun.misc.BASE64Encoder in HTTP basic authentication transactions. It works as expected under JRE 1.3.0 for Win9x/NT. Now I'm running JDK 1.4.1 on Mandrake Linux 9.0. This same application throws "error:Cannot find type "sun/misc/BASE64Encoder".
    Do I need a JAR file that was not packaged with JDK 1.4.1 for Linux? Any ideas on how to get this working?
    Thank you,
    J. Davis

    It's working now.
    Thank you for reading.

  • Any class can replace sun.misc.BASE64Encoder?

    In my program i want encode something, so i use the sun.misc.BASE64Encoder . But according to the JDK documents, i should not call "sun.*" package. In my applet program the access control exception occurs with the sun.misc. I have to give up the sun.misc.BASE64Encoder .
    Any other class replace BASE64Encoder that i can use?
    Please help me.
    Thank you very much!
    coral9527

    Read the whole page:
    http://iharder.sourceforge.net/xmlizable/

  • [svn] 1990: Reducing Base64Encoder buffer size from 64K to 32K to help with the smaller stack size of the AVM on Mac .

    Revision: 1990
    Author: [email protected]
    Date: 2008-06-06 18:53:36 -0700 (Fri, 06 Jun 2008)
    Log Message:
    Reducing Base64Encoder buffer size from 64K to 32K to help with the smaller stack size of the AVM on Mac.
    QE: Yes, please test mx.utils.Base64Encoder with Strings and ByteArrays larger than 64K on PC and Mac after these changes.
    Doc: No
    Checkintests: Pass
    Bugs:
    SDK-15232 - mx.utils.Base64Encoder.encodeBytes "toString()" or "flush" produces 1511 error on MAC
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-15232
    Modified Paths:
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/utils/Base64Encoder.as

    You can go with these options :
    http://musewidgets.com/collections/all/products/responsive-image
    http://musewidgets.com/collections/all/products/responsive-images
    Thanks,
    Sanjit

  • JCS is not supporting sun.misc.BASE64Encoder().encode()

    Hi All,
    We were used sun.misc.BASE64Encoder().encode() in one of our products and its not supporting in JCS. This class is not mentioned in white list errors. We are able to deploy this product in cloud and whenever it executes the above method its throwing an error and it is "Error Message: access denied (java.lang.RuntimePermission accessClassInPackage.sun.misc)". Please suggest work around for the above code.
    Thanks&Regards,
    Raghu

    Hi,
    Whitelist processing is our best effort to indicate what "will" work in Java Cloud Service. There are situations where we cannot definitively indicate if you are using an API that wont work on JCS. The runtime process is the source of truth. I have passed along this message to our development team. They will investigate and if possible introduce a warning in the whitelist in our next release. Thanks and I appreciate you pointing that out. This package is not supported in JCS.
    Thanks,
    -Anand.

  • PDF Image printing, base64encoded blobs

    Hi guys!
    I'm trying to extract images from a table (blob) and put it in a PDF-report, through ApEx.
    After reading this blogpost about image-blobs in reports(http://blogs.oracle.com/xmlpublisher/2006/05/05#a34) I thought "this was interesting, this is exactly what my customer want". So, I made a function to dump the blob as base64-data (found some codesnippets here and there..):
    function BLOB2CLOBASE64( p_blob IN BLOB ) RETURN CLOB
    IS
    pos PLS_INTEGER := 1;
    buffer VARCHAR2( 32767 );
    res CLOB;
    lob_len INTEGER := DBMS_LOB.getLength( p_blob );
    BEGIN
    DBMS_LOB.createTemporary( res, TRUE );
    DBMS_LOB.OPEN( res, DBMS_LOB.LOB_ReadWrite );
    LOOP
    buffer := utl_raw.cast_to_varchar2(utl_encode.base64_encode( DBMS_LOB.SUBSTR( p_blob, 32000, pos )));
    IF LENGTH( buffer ) > 0 THEN
    DBMS_LOB.writeAppend( res, LENGTH( buffer ), buffer );
    END IF;
    pos := pos + 32000;
    EXIT WHEN pos > lob_len;
    END LOOP;
    RETURN res; -- res is OPEN here
    END BLOB2CLOBASE64;
    Works great! I get the imagefile dumped as base64.
    So, time to try this out. I make a Report query in ApEx, and
    do a
    "select blob2clobase64(image_file) IMAGE from testphotos"
    XML gets dumped, and I can load it into my BI Publisher Desktop/Word. I do like it's done in the blogpost above, and enter the following for the IMAGE-field:
    <fo:instream-foreign-object content-type="image/jpg">
    <xsl:value-of select="IMAGE"/>
    </fo:instream-foreign-object>
    (In the examplecode from the above blog-link; see how this code is entered in the Help-section when you do "Properties" for the field).
    Ok, here goes, let's give it a try: Preview -> PDF and out pops two wonderful pictures that's in my table 'testphotos '. Hooray!
    I save the template, and upload it to ApEx through the Create Report Query-wizard. Go to the last page. Press "Test query". Out comes: A PDF-file with all the text from the template, but no pictures.
    What have gone wrong? Any inputs?
    Thanks for now,
    Vidar
    PS: Size of the 2 images together is 10-15kb max.
    PS2: Application Express 3.0.0.00.20
    Message was edited by:
    Vidar
    : added apex versioninfo

    Hello
    Just wanted to give this a bump, as I made this thread just before the weekend. It's dropped quite long, so thought I'd bring it upfront again now that people might be back.
    Regards,
    Vidar

  • How to access SOAP web service with authentication, HTTP basic Authentication

    Dear All
    i use Flash Builder 4.5, flex 4..1, i am developing a flex client to soap webservices hosted over Glassfish 2 Java server, the web services is protected by HTTP Basic Authentication, everythime i run my code , the prombt for username and password show up, i need to pass user name and password through action script, i followed the flollowing (but was for http web service, not soap) but really did not work.
    http://stackoverflow.com/questions/490806/http-basic-authentication-wi th-httpservice-objects-in-adobe-flex-air
    http://forums.adobe.com/message/4262868
    private function authAndSend(service:HTTPService):void
            var encoder:Base64Encoder = new Base64Encoder();
            encoder.insertNewLines = false; // see below for why you need to do this
            encoder.encode("someusername:somepassword");
            service.headers = {Authorization:"Basic " +encoder.toString()};                                               
            service.send();
    Also i noticed in debug mode, always that WARNNING raised up
    Warning: Ignoring 'secure' attribute in policy file from http://fpdownload.adobe.com/pub/swz/crossdomain.xml.  The 'secure' attribute is only permitted in HTTPS and socket policy files.  See http://www.adobe.com/go/strict_policy_files for details.
    any idea ?

    Hello,
    I don't know if this could help.
    Another way to connect to a web service by SOAP and WSDL is to click on the Data/Services panel, then click on "Connect to Data/Services" and then select the "Web Service" (WSDL) icon. This could help as well.

  • How to send JSON data in HTTPService to PHP web service question

    I'm using Flex 4 and a mx:HTTPService to send a JSON request to a php web service. I'm not sure if I'm sending the request correctly. Could someone look at the code below to see what I'm doing wrong?
    thanks
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   width="100%" height="100%">
        <fx:Declarations>
            <mx:HTTPService id="service" url="https://my web service url/"
                            method="POST" resultFormat="text" result="onResult(event)" fault="onFault(event)">
            </mx:HTTPService>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import com.adobe.serialization.json.JSON;
                import mx.collections.ArrayCollection;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.utils.Base64Encoder;
                [Bindable]private var username:String = "[email protected]";
                [Bindable]private var password:String = "the password";
                [Bindable]private var accountNumber:String = "49055";
                [Bindable]private var anticipatedDeliveryDate:Number = 20101115;
                [Bindable]private var purchaseOrder:String = "#123 for retailer";
                [Bindable]private var detailRecords:Array = new Array();
                [Bindable]private var key:String = "abc123";
                private function populateService():void {
                    populateProducts();   
                    setRequestHeader();
                    setRequestData();
                    service.send();   
                private function setRequestHeader():void {
                    var encoder:Base64Encoder = new Base64Encoder();
                    encoder.insertNewLines = false;
                    encoder.encode(key);               
                    service.headers["Authorization"] = "VIP " + key;
                    service.headers["Content-Type"] = "application/json";
                private function setRequestData():void {
                    service.request.username = username;
                    service.request.password = password;
                    service.request.accountNumber = accountNumber;
                    service.request.anticipatedDeliveryDate = anticipatedDeliveryDate;
                    service.request.purchaseOrder = purchaseOrder;
                    service.request.detailRecords = detailRecords;
                    // caching test
                    var rnd : Number = Math.round(Math.random()*1000);
                    service.request.cacheOff = rnd;
                private function populateProducts():void {
                    var prod1:Object = new Object();
                    prod1.itemCodeOrUPC = "00241";
                    prod1.itemDescription = "Budweiser Keg 1/2 BBL";
                    prod1.quantityOrdered = 2;
                    prod1.orderUOM = "Keg";
                    var prod2:Object = new Object();
                    prod2.itemCodeOrUPC = "00219";
                    prod2.itemDescription = "Budweiser 24/12 OZ CAN";
                    prod2.quantityOrdered = 4;
                    prod2.orderUOM = "Case";
                    detailRecords.push(prod1);
                    detailRecords.push(prod2);
                private function onResult(event:ResultEvent):void
                    var json:Object = JSON.decode(event.result as String);
                private function onFault(event:FaultEvent):void
                    trace("Fault: " + event.fault.faultString);
            ]]>
        </fx:Script>
        <mx:Panel width="95%" height="100%" color="#000000">
            <mx:HBox width="100%">
                <mx:Button label="Submit" click="{populateService()}"/>
            </mx:HBox>   
        </mx:Panel>
    </s:Application>

    Have you think abut using ActionScript in your Flex application? Or, you can write javascript to be proxy between your flash app and backend PHP web service?
    Also, it seems that you will allow every customer's flash player to have a copy of secret code. I think it is dangerous design because an flv file can be easity decompiled. Therefore, you secret code can be found if it is not input by your end user and it is populated on your serverside script.

  • Null check for "ora:readFile()" function

    Hi,
    I want to check whether a particular file is present in a given folder in our local server.In case of success scenario the "ora:readFile()" function is working fine but if the file is not present in the same folder then,this function is getting failed with system exception ,reason:-message can't be null.
    Can't we add a null check for this and continue the flow further?
    Regards,
    N.Das

    Hi,
    You should first try list operation in file adapter to check for the file then use the readfile() conditionally if file is found.
    Try the function to mention the path as
    ora:readFile(concat('file:',bpws:getVariableData('Invoke1_FileListing_OutputVariable','filelist','/ns1:filelist/ns1:file/ns1:directory'),'/',bpws:getVariableData('Invoke1_FileListing_OutputVariable','filelist','/ns1:filelist/ns1:file[1]/ns1:filename'))).
    This will get you the content in base64encoded format. You can then decode it to get the text format data.
    Thanks,
    Durga
    - It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts).*

  • Compatibility wtih 3DES

    I want to encrypt wtih 3DES in java and decryt in C. The same in the other way. The problem is that when I encrypt the same word with the same key in both languages, I get a different cipher test.
    Can anybody help me?
    I use this code to encrypt in JAVA:
    public class Encriptador {
         //Generamos la clave
    /*     private static final byte[] _3desData = {
             (byte)0x76, (byte)0x6F, (byte)0xBA, (byte)0x39, (byte)0x31, (byte)0x2F,
             (byte)0x0D, (byte)0x4A, (byte)0xA3, (byte)0x90, (byte)0x55, (byte)0xFE,
             (byte)0x55, (byte)0x65, (byte)0x61, (byte)0x13, (byte)0x34, (byte)0x82,
             (byte)0x12, (byte)0x17, (byte)0xAC, (byte)0x77, (byte)0x39, (byte)0x19 };*/
         static String clave ="012345678901234567890123";
         private static final byte[] _3desData = clave.getBytes();//{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
         private static SecretKeySpec _key = new SecretKeySpec(_3desData, "DESede");
    //  private static SecretKeySpec _key = Generador.clave();
         //Tenemos funciones de encriptar y desencriptar con cadenas y bytes
      public static String encrypt(String text){
        byte[] plaintext = text.getBytes();
        try{
          // Cogemos el objeto 3DES Cipher
          Cipher cipher = Cipher.getInstance("DESede");  // Triple-DES encryption
          // Modo encriptar
          cipher.init(Cipher.ENCRYPT_MODE, _key);
          // Encriptamos, pero pasamos a ASCII primero
          byte[] cipherText = cipher.doFinal(plaintext);
          BASE64Encoder b64 = new BASE64Encoder();
          return b64.encode(cipherText);
        }catch (Exception e){
          throw new java.lang.RuntimeException(e);
      public static String decrypt(String text){
        try{
          BASE64Decoder b64 = new BASE64Decoder();
          byte[] cipherText = b64.decodeBuffer(text);
          // Cogemos el objeto 3DES Cipher
          Cipher cipher = Cipher.getInstance("DESede");  // Triple-DES encryption
          // Modo desencriptar
          cipher.init(Cipher.DECRYPT_MODE, _key);
          // Desencriptamos
          String plainText = new String(cipher.doFinal(cipherText));
          return plainText;
        }catch (Exception e){
          throw new java.lang.RuntimeException(e);
        }

    Excuse me, I�m using as plaintext 0000111122220000.
    Yes, I�m now that use this keys make it a DES encrypt, but it only is to simplify yhe test.
    This is the C code. I can�t change it because it works in other aplications.
    void algorithms_DES (char tipo,UCHAR *d,UCHAR *c)
         int i,j;
         UCHAR k,val_car,d_i1[65],d_i2[65];
         UCHAR Edato[65],Eclave[65],Fresu[33],DatoR[33],Iclave[49];
         UCHAR permut_ini[65] = { 64,58,50,42,34,26,18,10, 2,60,52,44,36,28,20,12, 4,
                         62,54,46,38,30,22,14, 6,64,56,48,40,32,24,16, 8,57,
                          49,41,33,25,17, 9, 1,59,51,43,35,27,19,11, 3,61,53,
                         45,37,29,21,13, 5,63,55,47,39,31,23,15, 7
         UCHAR permut_fin[65] = { 64,40, 8,48,16,56,24,64,32,39, 7,47,15,55,23,63,31,
                         38, 6,46,14,54,22,62,30,37, 5,45,13,53,21,61,29,36,
                           4,44,12,52,20,60,28,35, 3,43,11,51,19,59,27,34, 2,
                           42,10,50,18,58,26,33, 1,41, 9,49,17,57,25
         ST(Edato,0,sizeof(Edato));
         ST(Eclave,0,sizeof(Eclave));
         ST(d_i1,0,sizeof(d_i1));
         ST(d_i2,0,sizeof(d_i2));
         ST(Fresu,0,sizeof(Fresu));
         ST(Iclave,0,sizeof(Iclave));
         ST(DatoR,0,sizeof(DatoR));
         Edato[0]=sizeof(Edato)-1;
         Eclave[0]=sizeof(Eclave)-1;
         d_i1[0]=sizeof(d_i1)-1;
         d_i2[0]=sizeof(d_i2)-1;
         Fresu[0]=sizeof(Fresu)-1;
         Iclave[0]=sizeof(Iclave)-1;
         DatoR[0]=sizeof(DatoR)-1;
         for (i=0,j=1 ; i<8 ; i++) 
              val_car=d;
              for (k=0x80 ; k>0 ; k/=2)
                   if ((k & val_car)!=0) Edato[j]=1;
                   j++;
         for (i=0,j=1 ; i<8 ; i++)
              val_car=c[i];
              for (k=0x80 ; k>0 ; k/=2)
                   if ((k & val_car)!=0) Eclave[j]=1;
                   j++;
         for (i=1 ; i<=permut_ini[0] ; i++) d_i1[i]=Edato[permut_ini[i]];
         for (i=1;i<=16;i++)
              ST(&d_i2[1],0,d_i2[0]);
              if (tipo==DEST_CIFR) algorithms_calc_Ki((UCHAR)i,Eclave,Iclave);
              else
              if (tipo==DEST_DESC) algorithms_calc_Ki((UCHAR)(17-i),Eclave,Iclave);
              else return;
              CP(&DatoR[1],&d_i1[33],DatoR[0]);
              algorithms_calc_F(Fresu,DatoR,Iclave);
              CP(&d_i2[1],&d_i1[33],32);
              for (j=1 ; j<=d_i2[0]/2 ; j++) d_i2[j+32]=(d_i1[j] ^ Fresu[j]);
              CP(&d_i1[1],&d_i2[1],d_i2[0]);
         CP(&d_i2[1], &d_i1[33],32);
         CP(&d_i2[33],&d_i1[1], 32);
         for (i=1 ; i<=permut_fin[0] ; i++) Edato[i]=d_i2[permut_fin[i]];
         ST(d,0,8);
         for (i=1 ; i<=Edato[0] ; i+=8)
              d[(i-1)/8] = (UCHAR)(Edato[i  ]*0x80)+(UCHAR)(Edato[i+1]*0x40)+
                   (UCHAR)(Edato[i+2]*0x20)+(UCHAR)(Edato[i+3]*0x10)+
                   (UCHAR)(Edato[i+4]*0x08)+(UCHAR)(Edato[i+5]*0x04)+
                   (UCHAR)(Edato[i+6]*0x02)+(UCHAR)(Edato[i+7]*0x01);

  • 3DES CBC mode

    My task to create a class that take 2 parameters 1)String Key, 2)String text then encrypt the string using the giving key and retrun the base64 encoding. My class seem working but the remote server did not decrypted.
    one thing of the vendor specification is the IV should match \0\0\0\0\ (8 bytes of null) I think I did not know what to do there :)
    here is the requirement:
    1- use padding of type "[PKCS5] PKCS #5, Password-Based Encryption Standard" (see http://www.di-mgt.com.au/cryptopad.html). Microsoft .NET automatically pads the string as needed by default.
    2- Encrypt the above resultant string using the Cipher Block Chaining (CBC) feedback mode of triple-DES encryption with an initial value for the feedback loop set to eight consecutive NUL (ASCII code 0) characters. The key to be used for this encryption is the key1. The cipher block chaining (CBC) feedback mode supports an additional, optional parameter named IV, which you'll need to implement as follows:
    *     The IV property contains the initial value which will be used to
    start a cipher feedback mode; it will always be a string of exactly one block in length. After encrypting or decrypting a string, this value is updated to reflect the modified feedback text. The parameter is read-only, and cannot be assigned a new value.
    *     If the mode property is set to MODE_CBC or MODE_CFB, the IV property
    must be provided and must be a string of the same length as the block size. Not providing a value for the IV property will result in a ValueError exception.
    *     The IV property must be an 8-byte string and its value must be:
    '\0\0\0\0\0\0\0\0' (a string of eight NUL characters)
    here is my code:
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    import java.io.*;
    import javax.crypto.spec.IvParameterSpec;
    import java.security.spec.AlgorithmParameterSpec;
    public class TDESStringEncryptor
    // private static int BLOCK_SIZE = 8;
         public static void main(String[] args)
              try
                   TDESStringEncryptor enc = new TDESStringEncryptor();
                   String value = enc.Encrypt(args[0], args[1]);
                   System.err.println(value);
              catch (Exception ex)
                   System.err.println(ex);
         public String Encrypt(String inkey, String data)
              throws Exception
              //--------------------- start ----------------------------
              //byte[] iv = new byte[]{(byte)0x8E, 0x12, 0x39, (byte)0x9C,0x07, 0x72, 0x6F, 0x5A};
              byte [] iv = {0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40};
         AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
              // convert key to byte array and get it into a key object
              byte[] rawkey = inkey.getBytes();
              DESedeKeySpec keyspec = new DESedeKeySpec(rawkey);
              SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede");
              SecretKey key = keyfactory.generateSecret(keyspec);
    Cipher c2 = Cipher.getInstance( "DESede/CBC/PKCS5Padding" );
    //----------------start ---------------
    c2.init(Cipher.ENCRYPT_MODE, key, paramSpec);
    //c2.init( Cipher.ENCRYPT_MODE, key );
    byte encodedParameters[] = c2.getParameters().getEncoded();
    byte[] out = c2.doFinal(data.getBytes() );
              Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");
              cipher.init(Cipher.ENCRYPT_MODE, key);
              //byte[] out = cipher.doFinal( padString(data).getBytes() );
              byte[] out = cipher.doFinal(data.getBytes() );
              //String tst = byteArrayToHexString( out );
         return new sun.misc.BASE64Encoder().encode(out);
         //return byteArrayToHexString( out );
         private String byteArrayToHexString(byte in[])
              byte ch = 0x00;
              int i = 0;
              if ( in == null || in.length <= 0 )
                   return null;
              String pseudo[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8",
                   "9", "A", "B", "C", "D", "E", "F"};
              StringBuffer out = new StringBuffer( in.length * 2 );
              while ( i < in.length )
                   ch = (byte) ( in[i] & 0xF0 );
                   ch = (byte) ( ch >>> 4 );
                   ch = (byte) ( ch & 0x0F );
                   out.append( pseudo[ (int) ch] );
                   ch = (byte) ( in[i] & 0x0F );
                   out.append( pseudo[ (int) ch] );
                   i++;
              String rslt = new String( out );
              return rslt;
    }

    Thanks for your help, I am just lost. can you explian
    to me what I need to use? I try to change DESede to
    DES but I get an eror. with the current setting the
    encryption work with no error.
    I appreciated if you refer to me a good source in the
    Internet to what I am missing.
    here is a test I did:
    C:\>java TDESStringEncryptor
    A7B08F3958039D5F23D5F5243563541D4792E501272B3486
    "This is a Test"
    and the result was: w/Ubo4XBYUQjmzI+6QVA==
    the developer at the other end whom using .NET send
    his result which is: HMueLH8gSr9y9sUZXfRFlw==I think I give up! DES or DESede are symetric algorithms and only have a 'secret' key. They do not have a 'public' key and a 'private' key.
    You need to start reading - http://www.cacr.math.uwaterloo.ca/hac/

Maybe you are looking for

  • How to  create PR automatically by sales order?

    Dear experts, I want to create PR automatically with sales order, and then create delivery from this sales order, and goods issue. I know third party order, however it can't create delivery. thanks Lance

  • Lcd problems on ipad 3

    my iPad 3 has a light colored band across the top 1/4 of the screen. it seems like the iPad does not want to display the color black.  This iPad has never been dropped before. Can anybody tell me the pixels are just stuck or is the LCD broken?

  • Packet Loss?? Need help!

    Over the past week I've been getting massive problems when gaming online with iRacing. I get halfway through a race and then I get kicked due to packet loss.  I did some ping tests and sure enough im losing between 2-5% of the total packets that were

  • Site Survey Fail?

    "Site Survey Failed" is the message I keep gettting when trying to setup my Wireless-G Expander on my computer. I am using a Wireless-G broadband router on my main computer, was told to buy the range expander to help retreive the signal across the ho

  • Address book has disappeared... twice!

    Hi there, This has happened to me twice, both times after Thunderbird updated itself. My Address book has been stripped of any contacts that Thunderbird automatically collected since i started using it way back. The first time it happened i had limit