Encoding using BASE64

Hi All,
i required some sample code for encoding using BASE64 encoding.
can any one please help in doing the code for encoding a text.
Thanks in advance.

There are quite a few examples of Base64 encoders and decoders on the web. I didn't see any written in Obj-C or coded with a Cocoa interface, but perhaps you might find one if you spend some time searching.
The example code you have is pure ANSI C, which means it can be added to any Xcode iPhone project as a separate file, wrapped into its own Obj-C class, or simply added to an existing class implementation. Since you only need to encode a short string, you'll only need the encode() and encodeblock() functions, along with the cb64[] array. encode() is expecting stdio FILE pointers for input and output, so you'll want to replace those parameters and the code which reads and writes from/to those streams with code that reads a C string (obtained from a NSString with UTF-8 encoding) and returns a NSData object.
If you're not a C programmer, you will need to get some help from one, but it should be an easy job. Of course you should review the MIT license to make sure you're in compliance. But the reason I selected this example for you is that it's so well documented, it will teach you everything you need to know to write your own code from scratch if you need to.
\- Ray
p.s.: Here's some Cocoa code I found for you: [http://www.cocoadev.com/index.pl?BaseSixtyFour] - R

Similar Messages

  • Help: URL encoded in Base64 not working with SP4

    With SP1, there was no problem but after installing SP4 (don't know whether it is accidental), this problem started occurring and I don't know what caused it. Here is the description:
    I have SP4 running on Solaris 8. An applet is launched and sends a servlet request to the server where the URL is encoded in Base64 (Post method) for some additional data. The servlet receives the request and attempts to decode the received URL since the parameters contain relevant info. While trying to decode the base64 parameter string back into Unicode, I see an exception:
    [23/Oct/2002:14:59:54] failure ( 6684): Internal error: exception thrown from the servlet service function (uri=/reports1/savereport): java.io.EOFException, Stack: java.io.EOFException
    at java.io.DataInputStream.readFully (DataInputStream.java:158)
    at java.io.DataInputStream.readUTF(DataInputStream.java:526)
    at java.io.DataInputStream.readUTF(DataInputStream.java:496)
    at com.xxxxxx.utils.Base64.decodeUnicodeString(Base64.java:236)
    My assumption is that the byte ordering may have been altered to cause this failure, but the Solaris OS version and the client machine's configuration did not change. Nothing else changed except the iPlanet version, which used to work otherwise.
    Has anyone seen this or does anyone know how to correct it? Will appreciate your response! Thanks in advance.

    hrstewart74 - You'll also need to send a Follow request to lindseyt_vzw that they'll have to approve.  Once you both are Following each other, then you can send them a Direct Message.
    How To: Direct Message

  • Can I change Encoding used in InputStreamReader

    Hi Java Gurus:
    Wanted to know if I can somehow change the encoding used by InputStreamReader, the value of which I get by InputStreamReader.getEncoding().
    I did change file.encoding to UTF8, but that does not change the encoding used by InputStreamReader.
    I am getting garbage data when reading a chinese character from a Swing GUI. If I convert the string into a byte array using utf8 encoding, the bytes look OK, but when I print the string, it is all garbage and gets stored in the database (thru JDBC) as garbage (?)
    Any pointer(s) would be a great help guys!
    Thanks,
    Micky G

    Hi Mickey,
    Wanted to know if I can somehow change the encoding used by InputStreamReader,
    the value of which I get by InputStreamReader.getEncoding().Easiest way is to specify the Charset or Charset name String in the constructor,e.g.:
    InputStreamReader isr = new InputStreamReader(iStream,  "UTF-16")
    I am getting garbage data....I don't quite follow what you're describing in this paragraph. Can you elaborate?
    Regards,
    Joe

  • XML Character Encoding Using UTL_DBWS

    Hi,
    I have a database with WINDOWS-1252 character encoding. I'm using UTL_DBWS to call a web service method which echoes a given string. For this purpose, I do the following:
    DECLARE
        v_wsdl CONSTANT VARCHAR2(500) := 'http://myhost/myservice?wsdl';
        v_namespace CONSTANT VARCHAR2(500) := 'my.namespace';
        v_service_name CONSTANT UTL_DBWS.QNAME := UTL_DBWS.to_qname(v_namespace, 'MyService');
        v_service_port CONSTANT UTL_DBWS.QNAME := UTL_DBWS.to_qname(v_namespace, 'MySoapServicePort');
        v_ping CONSTANT UTL_DBWS.QNAME := UTL_DBWS.to_qname(v_namespace, 'ping');
        v_wsdl_uri CONSTANT URITYPE := URIFACTORY.getURI(v_wsdl);
        v_str_request CONSTANT VARCHAR2(4000) :=
    '<?xml version="1.0" encoding="UTF-8" ?>
    <ping>
        <pingRequest>
            <echoData>Dev Team üöäß</echoData>
        </pingRequest>
    </ping>';
        v_service UTL_DBWS.SERVICE;
        v_call UTL_DBWS.CALL;
        v_request XMLTYPE := XMLTYPE (v_str_request);
        v_response SYS.XMLTYPE;
    BEGIN
        DBMS_JAVA.set_output(20000);
        UTL_DBWS.set_logger_level('FINE');
        v_service := UTL_DBWS.create_service(v_wsdl_uri, v_service_name);
        v_call := UTL_DBWS.create_call(v_service, v_service_port, v_ping);
        UTL_DBWS.set_property(v_call, 'oracle.webservices.charsetEncoding', 'UTF-8');
        v_response := UTL_DBWS.invoke(v_call, v_request);
        DBMS_OUTPUT.put_line(v_response.getStringVal());
        UTL_DBWS.release_call(v_call);
        UTL_DBWS.release_all_services;
    END;
    /Here is the SERVER OUTPUT:
    ServiceFacotory: oracle.j2ee.ws.client.ServiceFactoryImpl@a9deba8d
    WSDL: http://myhost/myservice?wsdl
    Service: oracle.j2ee.ws.client.dii.ConfiguredService@c881d39e
    *** Created service: -2121202561 - oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@afb58220 ***
    ServiceProxy.get(-2121202561) = oracle.jpub.runtime.dbws.DbwsProxy$ServiceProxy@afb58220
    Collection Call info: port={my.namespace}MySoapServicePort, operation={my.namespace}ping, returnType={my.namespace}PingResponse, params count=1
    setProperty(oracle.webservices.charsetEncoding, UTF-8)
    dbwsproxy.add.map: ns, my.namespace
    Attribute 0: my.namespace: xmlns:ns, my.namespace
    dbwsproxy.lookup.map: ns, my.namespace
    createElement(ns:ping,null,my.namespace)
    dbwsproxy.add.soap.element.namespace: ns, my.namespace
    Attribute 0: my.namespace: xmlns:ns, my.namespace
    dbwsproxy.element.node.child.3: 1, null
    createElement(echoData,null,null)
    dbwsproxy.text.node.child.0: 3, Dev Team üöäß
    request:
    <ns:ping xmlns:ns="my.namespace">
       <pingRequest>
          <echoData>Dev Team üöäß</echoData>
       </pingRequest>
    </ns:ping>
    Jul 8, 2008 6:58:49 PM oracle.j2ee.ws.client.StreamingSender _sendImpl
    FINE: StreamingSender.response:<?xml version = '1.0' encoding = 'UTF-8'?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><ns0:pingResponse xmlns:ns0="my.namespace"><pingResponse><responseTimeMillis>0</responseTimeMillis><resultCode>0</resultCode><echoData>Dev Team üöäß</echoData></pingResponse></ns0:pingResponse></env:Body></env:Envelope>
    response:
    <ns0:pingResponse xmlns:ns0="my.namespace">
       <pingResponse>
          <responseTimeMillis>0</responseTimeMillis>
          <resultCode>0</resultCode>
          <echoData>Dev Team üöäß</echoData>
       </pingResponse>
    </ns0:pingResponse>As you can see the character encoding is broken in the request and in the response, i.e. the SOAP encoder does not take into consideration the UTF-8 encoding.
    I tracked down the problem to the method oracle.jpub.runtime.dbws.DbwsProxy.dom2SOAP(org.w3c.dom.Node, java.util.Hashtable); and more specifically to the calls of oracle.j2ee.ws.saaj.soap.soap11.SOAPFactory11.
    My question is: is there a way to make the SOAP encoder use the correct character encoding?
    Thanks a lot in advance!
    Greetings,
    Dimitar

    I found a workaround of the problem:
        v_response := XMLType(v_response.getBlobVal(NLS_CHARSET_ID('CHAR_CS')), NLS_CHARSET_ID('AL32UTF8'));Ugly, but I'm tired of decompiling and debugging Java classes ;)
    Greetings,
    Dimitar

  • How can analog signals are measured every several counters from Quadrature Encoder using USB-6221

    how can I sample analog signals every counters from quadrature encoder using usb-6621?

    There is a well documented example of what you are trying to do at :
    http://zone.ni.com/devzone/explprog.nsf/webmain/DD85F07A7CA99F8F862568690062DE54?opendocument
    Don't be afraid because of the BNC-2120. It is just used in this example to simulate the pulses from a device. So it is not needed in your case. Obviously, you will need to change the number of increments/rev according to your encoder to get correct RPM values.

  • Since Firefox 4, I can get a background image to work using base64 encoded, but not a local file, this worked in Firefox 3, how do I resolve this.

    Using either of the 4 examples shown below, to have a background image display inside about:blank worked in Firefox 3.x (using Stylish add-on), however since Firefox 4, only using the base64 encoded version of images works. Is there any way to fix this so I don't have to encode every image I wish to use? Encoding the image makes the stylish file absolutely huge, & a real pain to keep encoding whenever I want to change the image.
    body:empty { background: url("resource:/res/images/OnFire.jpg")
    body { background-image: url("resource:/res/images/OnFire.jpg")
    body:empty { background:url("data:
    body { background-image: url("data:
    I've also previously disabled most of the add-ons, except for Status-4-Evar, Stylish, & Firebug, in an attempt to see if something else was interfering, but no change.
    I can supply a copy of the previously working (FF 3.x) code to some of the about:blank styles if needed for testing purposes.

    Type '''about:addons'''<enter> in the address bar to open the '''Add-ons Manager.'''
    Hot key; '''<Control>''(Mac:<Command>)'' <Shift> A)'''
    On the left side of the page, select '''Plugins.'''
    Is it listed here? Select '''Disable.'''

  • Flash Builder 4.5 SOAP call for images using Base64 Encoding

    I am trying to load some image meta data in a flash builder mobile application by making a SOAP call to .Net service. I am able to test the web service successfully using a .Net console application. However when I make the call from flash builder mobile client I get a null result. What am I doing wrong? I am using SOAP 1.1 ByteArray didn't work for Flash builder. So converted the ByteArray to Base64 format and tried to obtain result that way. Both ways worked from a .Net Client but not working from Flash mobile.
    Here is the code
    <fx:Script>
            <![CDATA[          
                import mx.graphics.ImageSnapshot;
                import mx.graphics.codec.JPEGEncoder;
                import mx.graphics.codec.PNGEncoder;
                import mx.rpc.AsyncToken;
                import mx.utils.Base64Encoder;         
                import services.exifimagemetadata1.ExifImageMetaData1;         
                import spark.components.Image;     
                public var metaData:ExifImageMetaData1 = new ExifImageMetaData1();         
                public var imageBytes:ByteArray = new ByteArray();
                public var gpsData:String;
        private function getBase64EncodedImage():String
                    var myEncoder:Base64Encoder = new Base64Encoder();
                    myEncoder.encodeBytes(getImageBytes());            
                    var image64BitText:String = myEncoder.toString();                          
                    return image64BitText;
        public function GetMetaDataFromExif():void{
                    var imageToken:AsyncToken = metaData.GetExifBase64Data(getBase64EncodedImage());               
                    gpsData = imageToken.result.toString();
                    metaResult.text = gpsData;
        protected function GetImageMetaDataFromExif(event:MouseEvent):void
                    GetMetaDataFromExif();         
            ]]>
        </fx:Script>
    <s:layout>
            <s:VerticalLayout>         
            </s:VerticalLayout>
        </s:layout>
        <s:HGroup>
            <s:Image id="test" width="130" height="140" source="@Embed(source='assets/p1000106.jpg')"/>
        </s:HGroup>
        <s:HGroup>
        <s:Label width="100" height="140" backgroundColor="Blue" click="GetImageMetaDataFromExif(event)">
            <s:text/>
        </s:Label>
        </s:HGroup>
        <s:HGroup>
            <s:Label id="metaResult" width="200" height="140" backgroundColor="yellow"/>           
        </s:HGroup>

    Hello everyone -
    Since I last posted an interesting update happened. I tested my  Flex application again, it is calling a Jetty Server that returns a JSON object, in different BROWSERS.  I disabled HTTPS for now, and the crossdomain.xml policy file is wide open for testing (ie. allowing every request to return data). So the app accessing the data using HTTP only. Browsers  -  IE, Opera, Firefox and Chrome. Each browser contained the SAME application, revision of the Flash Player (10.3.183.10 debugger for firefox, chrome, opera, safari PC; 11.0.1.129 consumer version in IE9,) take a look at the screen shot (safari not shown although the result was the same as IE and chrome)
    Note that Opera and Firefox returned successful values (i.e. successful JSON objects) using the same code generated from the Data Services Wizard. Chrome, IE and, Safari failed with an Internal error. So I am left wondering - WHY? Is it something with the Flash Player? the Browsers?  the Flex SDK? Any thoughts are appreciated. Again, the code is found in the original thread above.

  • Transfer of JPG Attachment through web method using BASE64 encoding

    Hello!
    I have an existing ABAP program which sends information (.txt file) by calling a web module. I need to change this program so  that users can attach a .Jpg image. The image has to be sent along with the other information by calling the web module but the encoding has to be BASE64. Do anybody know how this is done ?
    Annbjørg

    Hi
    Check this Blog
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/encodingBASE64in+ABAP
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/decodingBASE64in+ABAP
    Regards
    Pavan

  • Java Crypto - X.509 Certificate - DER encoded to Base64

    How to convert DER encoded X.509 Certificate to Base64 encoded X.509 Certificate?

    One way is to use the keytool utility supplied with the jdk. My keystore is already set up so you may have some additional steps beyond what I show below.
    First import the DER encoded certificate
    keytool -import -alias tempaliasname -file file.der(you will be prompted for the keystore password)
    Then export to Base64
    keytool -export -alias tempaliasname -file file.cer -rfc(you will be prompted for the keystore password)
    That will give you the Base64 version of your certificate.
    You can use the keytool -delete command to delete the key from your keystore if you want.
    Bruce

  • PDF to encode  in BASE64

    Hi,
    I need to encode the result of the function CONVERT_OTFSPOOLJOB_2_PDF in base64. For this i use the method
    cl_http_utility=>if_http_utility~encode_base64. Our system is in unicode.
    Have already done it ?
    If yes, can you tell me the way to do it.
    Thanks.
    ISIS.

    Did you try it yourself first or did you use where-used on the method?

  • SOAP encoding gzip + base64

    Hi Experts,
    I have a scenario where I have a SOAP receiver that accepts only messages with gzip compact and base64 encoding, in this order. That means I must first compact the message with gzip and then convert this result into base64 encoding.
    I tried to do so using the SOAP default module (XISOAPAdapterBean) with this configuration parameters:
    XMBWS.Encoding = gzip
    XMBWS.TransferEncoding = base64
    XMBWS.XMLEncoding = base64
    When I run that configuration, however, the following error occurs in the processing (viewed via sxmb_moni):
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.io.UnsupportedEncodingException: base64
    Are the parameters correct?
    Can I see the sequence of the operations (compact and encode)?
    Is there anyway to configure this sequence?
    Any other sugestions?
    Thanks

    Hi,
    After delete the line "XMBWS.XMLEncoding = base64", the server began to return this error: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.io.IOException: invalid content type for SOAP: TEXT/PLAIN; HTTP 415 Unsupported Media Type
    I made another test, configuring the parameters according to the guides, like this:
    XMBWS.XMLEncoding = charset iso-8859-1
    XMBWS.TransferEncoding = base64
    XMBWS.Encoding = gzip
    XMBWS.AcceptEncoding = compress, gzip
    But the same error occurs: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.io.IOException: invalid content type for SOAP: TEXT/PLAIN; HTTP 415 Unsupported Media Type
    Is there anyway to check the operations sequence (first compact then encode)?

  • Using base64 in applet

    Hey,
    I want to use the base64 encoder in my applet but I get faults.
    I think the problem is that he doesn't recognize the BASE64Encoder.
    This is my code:
    //some other imports
    import javax.crypto.spec.PBEParameterSpec;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.*;
    import java.security.*;
    // This is for BASE64 encoding and decoding
    import sun.misc.*;
    public class Demo4 extends Applet{
    //some code
    public String encrypt(String pass, String plaintext)
              throws Exception
              char[] password = pass.toCharArray();
              byte[] ciphertext = plaintext.getBytes();
         //herkend BASE64Encoder niet
              BASE64Encoder encoder = new BASE64Encoder();
              String ciphertextString = encoder.encode(ciphertext);
              return encoder.encode(ciphertext);
    This function I want to call in my html page using javascript.
    Does anyone know what the problem can be?

    Don't use the sun.misc.* classes. They are undocumented, subject to change, and may not be included with all distributions of Java.
    There are many alternatives out there for Base64 encoding. I have written one:
    http://ostermiller.org/utils/Base64.html
    You can include it in your applet.
    Stephen

  • Quicktime encoding using x264 encoder failing in AME 6.0.2.81 and Mac OS 10.8.2

    I'm trying to encode an x264 codec Quicktime using AME 6.0.2.81 and Mac OS 10.8.2. I also tried it with two versions of the x264 encoder which I downloaded from here: http://www.macupdate.com/app/mac/24173/x264encoder
    This encoder works 100% fine and better than the h264 encoder when using Apple Compressor and Apple QT Pro V7. I've been however trying to transition all of my video encodes to AME due to a number of reasons: dynamic link to AE, Premiere and the interface to name a few.
    Everytime I start an encode it gives me an error and I hear that blasted sheep. lol. This is what the log displays, which is frankly probably no help to anyone.
    - Encoding Time: 00:00:00
    01/13/2013 04:48:10 PM : Encoding Failed
    Export Error
    Error compiling movie.
    Unknown error.
    I've also tried to specify the bitrate and have had no luck. Whether I specify the bitrate or not, I still get the error. The source video has been PNG sequences and ProRes movies at 1920x1080, 29.97fps. Both result in the same unknown error.
    Any suggestions? Thanks!

    I know this is pretty old now, but I thought I'd add a reply for those who are having this issue. I just had AME CC 2014 fail on me today, and this is the FIRST thing I've ever tried to render with it. I'm using a TGA sequence and exporting to an X264 codec Quicktime MOV file at 720p. I restarted a few times, repaired permissions etc. and nothing worked except for the following.
    I went to:
    Library/Preferences/Adobe/Adobe Media Encoder/8.0/
    I deleted the entire 8.0 folder (or you could delete whatever version you are having problems with). I then restarted AME and the preferences were recreated and I could successfully use the x264 codec again. Hope this helps someone.

  • How do I find out the encoding used to import music?

    I want to be sure that all of my music is imported using apple lossless encoding. Can I tell from the file somehow or do I have to re-import everything? thanks

    Select a track in your iTunes library that you have imported
    Select 'Get Info'
    It will then tell you what format it is in
    You can also go to the View menu and turn on listing a column called 'Kind' which will say whether it is lossless or not.

  • DVD encoding using transcode results in out-of-sync audio

    I am trying to encode my DVDs for easy viewing on my computer. I am trying to do this with transcode, but I am having a few problems.
    Firstly, I use lsdvd and tccat to find and rip the desired content in raw form from the DVD to a VOB file. Once I have this raw data, I then encode the file to an AVI, using a command like:
    transcode -i <name>.vob -N 0x2000 -w 1000 --nice 10 -F mpeg4 -y ffmpeg,raw -o <name>.avi"
    Which compresses the video to mpeg4 with ffmpeg and copies the audio from the original as-is into the AVI file. However, when I watch the resulting movie, the audio runs slightly ahead of the video, so people's lips continue to move after they've finished speaking, just like in a badly-dubbed kung-fu flick!
    Another problem I've noticed (perhaps related?) is that despite the fact that the audio stream ought to be a bit-for-bit copy of the original, the bitrate is written as 128kb/s instead of 192kb/s like it should be. If the argument -b 192 is given then it fixes this problem, but the first problem is still present so it's not the cause of that.
    Encoding in mencoder using exactly the same technique works fine, but I hate mencoder and mplayer because they are both brain-dead and buggy. Mencoder won't detect half of the stuff it should, e.g. the aspect ratio, forcing me to look at every DVD I encode, read the aspect ratio and set it manually, which is just not on. I need to use transcode anyway to rip the DVD image, since mencoder claims that it can't acutally read the DVD half the time when everything else can, so if I can just get past this stupid problem then I will be happy.
    So, if anyone can help me figure out the problem here I'd be very grateful

    Argh! I never even noticed that option, despite having read the man page about 7 million times. Acidrip is not so great IMO, I think it uses MEncoder, so it suffers from the same problems I highlighted earlier, plus it is very crude and buggy. IIRC it also seems to be biased towards single-pass encoding, which is stupid because for a little more time you can get better quality with multi-pass as long as you're happy with running an encoding process in the background for a few hours (not such a big deal as long as you nice it down to a low priority)

Maybe you are looking for