w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Apache commons base64 decode and Sun base64 decode
The decoded data is not valid Base64 data. Valid Base64 data can contain whitespace. Usually, it has a newline every 72 characters. However, your data contains spaces in random places. If they are removed (as every Base64 decoder is supposed to do), 339 characters remain. Yet, valid Base64 data has to be a multiple of 4 characters. Interestingly, your data contains no plus signs. I suspect it once contained them but they have probably been replaced with spaces somewhere in transmission. If you replace all spaces with plus signs, the Base64 data is valid and the decoded data will have a length of 256 bytes: 344 characters / 4 * 3 - 2 padding characters. I further suspect that the Base64 data was used in a URL without proper URL encoding. That's a probable cause for the missing plus signs

Categories : Java

Decode Base64 url in Java
You can use org.apache.commons.codec.binary.Base64 package available in Java for the same. Sample code(not tested though) : Base64 decoder = new Base64(); String url = "aHR0cDovL05jLmtwaS51YS9hdXR1bW4yMDEz"; byte[] decoded = Base64.decodeBase64(url); System.out.println(new String(decoded, "UTF-8") + " ");

Categories : Java

Cant base64 decode from mysqli
There are many errors with your code: I fixed them. $type = $_SESSION['SESS_ACC_TYPE']; $login = $_SESSION['SESS_LOGIN_NAME']; if ($type == '2') { $qry = "SELECT `log` FROM `logs`;"; } if ($type == '1') { $qry = "SELECT `log` FROM `logs` WHERE `login` = '" . $login . "';"; } $result = mysqli_query($GLOBALS["___mysqli_ston"], $qry); while($row = mysqli_fetch_assoc($result)) { echo base64_decode($row['log']); }

Categories : PHP

Query a base64 image from sql and decode it
try this code, please justify according to your code: $data = json_decode($json, true); //print_r($data); $picture = base64_decode($data['posts'][0]['picture']); header("Content-type: image/png"); echo $picture; You must decode only decoded data for the image, and don't forget to use header

Categories : PHP

Android can't decode PHP base64 code
if the invalid trailing byte is a carriage return ( ), the easiest solution would be to leave out the closing PHP tag (on all of your PHP files): <?php //Code goes here //Leave out the closing tag: ?> Otherwise, you may be able to trim surrounding whitespace and carriage returns (in your Java code), before you base64 decode it.

Categories : Java

Get cyrillic result from base64.decode
You'll want to do: result= new String( Base64.decode( text, Base64.DEFAULT ), "ISO-8859-5" ); Please change ISO-8859-5 to suit your needs, but this should be standard cyrillic charset encoding.

Categories : Android

best way to encode and decode a file to base64 or base128?
Your best bet is to use the ToBase64Transform and FromBase64Transform crypto interfaces. The basic gist behind this code sample is that you use the From/ToBase64Transform transform class with the standard crypto stream to handle the heavy work of converting the incoming data to or from base64. In the ConvertToBase64 method, you'll notice that it wraps the destination file stream with the "ToBase64" crypto stream and we then copy the contents from the source stream to the base64 crypto stream. It's the same when decoding, you just apply it slightly backwards. We wrap the source stream in a "FromBase64" to decode the data as it comes in and we use it to copy it to the destination stream. A very rough (and untested example) would be something like: using System; using System.IO; using Syst

Categories : C#

Out of memory while decoding Image using Base64 Decode
You can simply use this and get better solution: public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix = new Matrix(); // RESIZE THE BIT MAP matrix.postScale(scaleWidth, scaleHeight); // "RECREATE" THE NEW BITMAP Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); return resizedBitmap; }

Categories : Android

How to decode the image which is a base64 string, in Dart?
Try using the crypto package from the Dart SDK. This creates an image.png that opens fine (I believe it's this image... ) library foo; import 'package:crypto/crypto.dart'; import 'dart:io'; void main() { var body = "data:image/png;base64,iVBORw0KGgoAAAANSUh... snip"; var prefix = "data:image/png;base64,"; var bStr = body.substring(prefix.length); var bytes = CryptoUtils.base64StringToBytes(bStr); // using CryptoUtils from Dart SDK var file = new File("image.png"); file.writeAsBytesSync(bytes); } You'll need to add crypto to your pubspec.yaml : dependencies: crypto: any The library linked at https://github.com/wstrange/base64, also notes in the README: Deprecated Note: The Dart SDK now includes a Base64 codec with url safe options. Unless you need streami

Categories : Image

base64 decode 2 items in array and still output for json?
Try changing: $output['shortCopy']=base64_decode(); to: $output['shortCopy'] = base64_decode($output['shortCopy']); The problem was that nothing was being decoded, since you put the string to be decoded inside the "()" in base64_decode();

Categories : PHP

Decode base64 encoded file and print results to the console
Unless I'm overlooking something, this is as simple as reading in your encoded string and then calling the standard library's base64.b64decode function on it. Something like: with open(path_to_encoded_file) as encoded_file: print base64.b64decode(encoded_file.read().strip())

Categories : Python

encode and decode base64 excpetion storing to sql server 2008 r2
As I also commented (and responded) on jdbc stored png image at sql server 2008 r2 gives not complete data older version of SQL Server had a limit of 8kb for varbinary and varchar. Either the driver simply doesn't support longer for getBytes or getString, or you might be using an older JDBC driver. Another possibility is that you need to register the OUT parameter as java.sql.types.LONGVARBINARY (or LONGVARCHAR). In any case (also in the other question), I am wondering why you are first encoding in base64 before storing your data. Just store the raw bytes in a VARBINARY.

Categories : Java

How to base64 encode/decode a variable with string type in Python 3?
You need to encode the unicode string. If it's just normal characters, you can use ASCII. If it might have other characters in it, or just for general safety, you probably want utf-8. >>> import base64 >>> s = "12345" >>> s2 = base64.b64encode(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> File ". . . /lib/python3.3/base64.py", line 58, in b64encode raise TypeError("expected bytes, not %s" % s.__class__.__name__) TypeError: expected bytes, not str >>> s2 = base64.b64encode(s.encode('ascii')) >>> print(s2) b'MTIzNDU=' >>>

Categories : Python

PHP - get base64 img string decode and save as jpg (resulting empty image )
AFAIK, You have to use image function imagecreatefromstring, imagejpeg to create the images. $imageData = base64_decode($imageData); $source = imagecreatefromstring($imageData); $rotate = imagerotate($source, $angle, 0); // if want to rotate the image $imageSave = imagejpeg($rotate,$imageName,100); imagedestroy($source); Hope this will help. PHP CODE WITH IMAGE DATA $imageDataEncoded = base64_encode(file_get_contents('sample.png')); $imageData = base64_decode($imageDataEncoded); $source = imagecreatefromstring($imageData); $angle = 90; $rotate = imagerotate($source, $angle, 0); // if want to rotate the image $imageName = "hello1.png"; $imageSave = imagejpeg($rotate,$imageName,100); imagedestroy($source); So Following is the php part of your program .. NOTE the change with comment Ch

Categories : PHP

Send Base64 image from Android with JSON to php webservice, decode, save to SQL
I wanted to post my solution in case anyone else is having trouble with this. I always come to S.O. for answers so now it's my turn to help someone out. I was having problems with out of memory errors using the bitmaps. I changed it to a multipart post to upload the picture as a file and a string like their name but you could add any string to it. The first part is the android side and below that is the php for the database. The picture is added to a file in the directory with the move file method. The database stores the path to that picture. I searched for two days to piece it together all from stack overflow posts. ANDROID public void onClick(View v) { if (v.getId() == R.id.capture_btn) { try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

Categories : PHP

How to cache expressjs response
connect-cache should do the trick. Add this to your app as a middleware var connect_cache = require('connect-cache'); app.use( connect_cache({rules: [{regex: /.*/, ttl: 60000}]}) );

Categories : Node Js

Render view into a variable in ExpressJS (for AJAX response)
In express you can use app.render with a callback to render a view and get the html: app.render('employees', {layout: false}, function(err, html){ var response = { some_data: 'blablabla', some_more_data: [5, 8, 10, 67], my_html: html }; res.send(response); });

Categories : Ajax

NodeJS/ExpressJS send response of large amount of data in 1 stream
Node's http.request() returns data in chunks for streaming (would be nice if they explicitly state this). Thus it's necessary to write each chunk to the body of Express's response, listen for the end of the http request (which is not really documented), and then call response.end() to actually finish the response. var req = http.request(options, function(res) { res.on( 'data', function(chunk) { response.write(chunk); } ); res.on( 'end', function() { response.end(); } ); } ); req.on('error', function(error) { … }); req.end(); Where response is Express's response the the initial client request (curl or angular's ajax call).

Categories : Node Js

URL decode all values in xml document in php
you can run $value = urldecode( $value ) which will decode your string. See: http://www.php.net/manual/en/function.urldecode.php

Categories : PHP

print BASE64 coded image into a FPDF document
While the comments suggested a TCPDF solution, I did want to state that there is a way to do this entirely with FPDF. The thought process is like this: Strip data:image/png;base64, from the URI using explode Decode the URI with base64_decode Save the decoded data to a PNG file with file_put_contents Generate a PDF and add the PNG file with Image Delete the PNG file with unlink Always remember to error check. If the image fails to save to the server you obviously do not want to continue execution. Make sure to always strictly check if the functions return false! Here is my solution. I used a tiny image for a small URI in this example. const TEMPIMGLOC = 'tempimg.png'; $dataURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAPCAMAAADarb8dAAAABlBMVEUAAADtHCTeKUOwAAAAF0lEQVR4

Categories : PHP

How to decode encrypted SAML response from idP with PHP?
Please check the One Login SAML php library, It is well documented and coded. You can easily use it to processResponse and the getAttributes do what you want. I know the question is old, But it may help someone still looking for the same.

Categories : PHP

Load a PDF document from remote server into base64 encoded data
As you have said there are cross domain restrictions that prevent you from downloading any old file from another domain. There are a couple of ways round this. If the server you're downloading from supports CORS requests then you should be able to download the file as a binary object. If you're downloading from a server you control then you could update it to support CORS requests. If CORS support on the originating server isn't an option then you could create a proxy on your server to download the PDF and pass it on to the client. Either host it on the same domain or make sure it supports CORS requests from your domain.

Categories : Javascript

can i display excel and word document from base64 encoded data to webpage?
Are you using embed for the word docs as well? Try using object as below: <object data="file:///C|/myfile.doc" type="application/msword" style="width:100%;height:100%;"></object>

Categories : PHP

Need to encode/decode a JSON response for passing it to another webpage
you could use the encodeURIComponent before sending $("#empStatus").val(encodeURIComponent(JSON.stringify(empStatus))); //in JS and the decodeURIComponent when receiving, thus it will protect from special enclosing characters like "

Categories : Javascript

Transfering Base64 String over Http REST service with JSON response
Try this methods works perfectly with me HttpResponse WSresponse = httpclient.execute(httppost); String response = getResponseBody(WSresponse.getEntity()); JSONObject jobj = new JSONObject(response); public String getResponseBody(final HttpEntity entity) throws IOException, ParseException { System.out.println("GEN START : " + Calendar.getInstance().getTimeInMillis()); if (entity == null) { throw new IllegalArgumentException("HTTP entity may not be null"); } InputStream instream = entity.getContent(); if (instream == null) { return ""; } if (entity.getContentLength() > Integer.MAX_VALUE) { throw new IllegalArgumentException( "HTTP entity too large to be buffered in memory");

Categories : Java

Issue in following expressjs statement, picked from Expressjs.com
I can figure out the following use case of the above statement. var user= {}; user.load = function(req, res, next){ console.log(req.params.id); next(); } app.get('/user/:id', user.load, function(req, res){ // ... res.render('home'); }); You are right, it would take the declaration of the object user but then it gives you to define additional callback functions, for additional validation/manipulation.

Categories : Node Js

expressjs middleware next function vs response objects next function
Yes, it is the same function as can be seen here in the source code. Yes, I would say it's use is discouraged because it is undocumented and also unnecessary since each middleware function will get next passed in as the 3rd argument.

Categories : Node Js

Base64.encode(bytearray, Base64.DEFAULT) result of this method will add 10 at last item
I can't comment right now so i had to leave a reply. Is this code written by you? or Someone else? For Base64 encoding, byte are processed in blocks of 3 bytes at a time. If the length of the array is not a multiple of three then either one or two '0' zero bytes is appended to make full block. And why are you writing your own logic where there are some API available to do the work for you? Update: I just run the code again with help of API. Input String: 51b034267f00000144495444 And Corresponding Base64 encoded String: NTFiMDM0MjY3ZjAwMDAwMTQ0NDk1NDQ0 Simply put, 3 bytes will result in 4 plain text encoded bytes.

Categories : Java

Python 2.7 decode error using UTF-8 header: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3
I'm not sure, but I think the culprit is the "u" character at the start of u"%s: %s". This is assuming that what you want to print is a byte string and not a unicode string --- which would be reasonable(*): you output bytes, suitably encoded. Modified like this: print '%s: %s' % (category['name'].encode('utf-8'), category['id']) this would turn the unicode string category['name'] to a UTF-8 byte string, and then the rest of the processing is done with byte strings. (*) It is reasonable in one point of view; another point of view is to print unicode strings and let the environment decide how it should be encoded, but then you're at the mercy of several factors that you don't really control. That's why you see differences between the output going to the terminal or to a file. To avoid

Categories : Python

Unable to decode russing string with encodeURIComponent and java.net.decode
I misunderstood your question be the formatting of it. Use decodeURIComponent to decode url encoded strings in JavaScript: > decodeURIComponent('%D1%8D%D1%82%D0%B8%D0%BA%D0%B5%D1%82%D0%BA%D0%B0') "этикетка";

Categories : Java

Jquery Ajax response object document
$.get("http://localhost/proiect/domr.php", { url: "http://www.info.uaic.ro",type:"svg",hox:"html" },"xml" ) .done(function(data) { alert("Data Loaded: " + data); $("#tree").append(data); .append() should be used instead of .html().

Categories : Jquery

AJAX response with undefined/object document
Your question is rather unclear, it seems to me that you're getting undefined as your response and that that's your problem. Maybe try changing "http://localhost:8080/services/web?wsdl/authen" to "/services/web?wsdl/authen" Or changing data: dataString, to data: { client: clin, username: us }

Categories : Javascript

Document response classes with Swagger and ServiceStack
Here's what the ServiceStack Swagger implementation currently supports, as of version 3.9.59: Optional: only nullable value types are described as optional. Other than that, there is currently no support for explicitly defining which properties in the request/response body are optional. For path or query string parameters, you can control optionality using ApiMemberAttribute Allowed values: enum types will automatically get a list of allowed values. For other types (e.g. a string property with a predefined set of values), annotate the property with the ApiAllowableValues attribute Description: use the System.ComponentModel.Description attribute Make sure your request DTO implements the IReturn<ResponseDtoType> interface. The following is probably the closest approximation to the

Categories : Api

Ad call response in ajax success contains document.write
Sending the ajax request from an iframe context should do the trick, or at least you can parse the ad result code to replace document.write calls with DOM related functions. Example using an iframe context to evaluate ajax response: var adCode = "document.write('example')", iframe = document.getElementById('myFrame'); iframe.contentWindow.eval(adCode);

Categories : Javascript

decode two values using oracle decode
Why do you want to use DECODE? CASE would seem like a much better fit CASE WHEN status_a = 'Y' and status_b = 'Y' THEN 'Y' WHEN status_a = 'Y' and status_b = 'N' THEN 'N' WHEN status_a = 'N' and status_b = 'Y' THEN 'N' WHEN status_a = 'N' and status_b = 'N' THEN 'N' END Of course, the logic you posted does not appear to make sense. The only way that status_a = 'Y' or status_b = 'Y' would evaluate to FALSE while status_a = 'Y' or status_b = 'N' evaluated to TRUE would be if status_a = 'N' and status_b = 'N'. But that means that the third and fourth branch would never be reached. If you meant and rather than or, the logic would make sense. But in that case, you could simplify it to CASE WHEN status_a = 'Y' and status_b = 'Y' THEN 'Y' ELSE 'N' END

Categories : Oracle

how to get base64 pdf string working in IE ( base64 pdf string is coming from odata call)
Answer from How can I make a link in IE using base64 encoding method?: According to this you cannot use data uri for navigation in IE. Internet Explorer through version 7 (approximately 5% of web traffic as of September 2011), lacks support. However this can be overcome by serving browser specific content.[6] Internet Explorer 8 limits data URIs to a maximum length of 32 KB. (Internet Explorer 9 does not have this limitation)[4][3] In IE 8 and 9 data URIs can only be used for images, but not for navigation or Javascript generated file downloads. [7]

Categories : Jquery

Setting Cookies via AJAX CORS Response and accessing them in document.cookies
The only interface JavaScript (on a webpage) has for reading cookies is document.cookie which contains the cookies for the current HTML document. Cookies set via a cross-domain Ajax request are not for the current HTML document, so are not available through that interface. XMLHttpRequest does have a getAllResponseHeaders() method, but Set-Cookie headers are suppressed by browsers so you can't access them as they are being set either.

Categories : Javascript

.NET RSAKeyValue base64 private key to a single base64 private key
The XXXX in the RSAKeyValue XML are in base64, just that i do not want to expose the details there. I want to know how do i combine all the XXXX base64 codes into a single base64 private key. I suspect that this means that you are performing the base64 encoding line by line. It's much simpler to perform the encoding on the entire file. For example you might do this as follows: Load the file into a TStringList. Extract a single string representing the file using the Text property of the string list. Base64 encode that string. Send it over the wire. At the receiving end, decode the string. Assign the string to the Text property of a string list.

Categories : Delphi

Expressjs without templates
I think the debate is the same for Node.js than for any other tech. With a classic MVC solution and server side template, all the computation is made server side and pure HTML is sent to the client. The response could take longer but the browser, and the client computer, are not heavily used. It's easiest to maintain if you are not confident in client side Javascript. I think it would be easiest as well for caching. On the other side, the match up solution, made generally by calling API with Ajax, put more heavy computation on the client browser and leave your server globally alone. You can even think about a full static page for example that populate his content only with JavaScript. You have to be more confident with JavaScript (And use stuff like Angular.js for example). The response

Categories : Ajax

Two apps in expressjs
See the vhost example on the express github repository. You can have a "main" app, which routes the requests to one app or another. You should write a middleware to establish the conditions where one app or another are requested. express.vhost is a good example, but maybe you need other checks than the domain one. main-app.js (The file called to start the server.) // load dependencies var main = express(); main.use( express.vhost( 'mobile', require( './the-mobile-app' ) ); main.use( express.vhost( '*', require( './the-web-app' ) ); main.listen( /*...*/ ) the-mobile-app and the-web-app.js var app = express(); // // setup your application conf, middleware, and routes // module.exports = app;

Categories : Node Js



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.