if encoding using escape(data) in javascript, how to deconde it in server side?
I use ajax to post encoding data with escape javascript function, how can I decode it at the server side with classic asp
Is there a common method to encode and decode arbitrary data so the encoded end result consists of numbers only - like base64_encode but without the letters?
Fictitious example:
$encoded = numbers_encode("Mary had a little lamb");
echo $encoded; // outputs e.g. 122384337422394237423 (fictitious result)
$decoded = numbers_decode("122384337422394237423");
echo $decoded; // outputs "Mary had a little lamb"
Yesterday I posted this queston.
Today I found the code which I need but written in Ruby. Some parts of code I have understood (I don't know Ruby) but there is one part that I can't. I think people who know ruby and php can
help me understand this code.
def do_create(image)
# Clear any old info in case of a re-submit
FIELDS_TO_CLEAR.each { |field| image.send(field+'=', nil) }
image.save
# Compose request
vm_params = Hash.new
# Submitting a file in ruby requires opening it and then reading the contents into the post body
file = File.open(image.filename_in, "rb")
# Populate the parameters and compute the signature
# Normally you would do this in a subroutine - for maximum clarity all
# parameters are explicitly spelled out here.
vm_params["image"] = file # Contents will be read by the multipart object created below
vm_params["image_checksum"] = image.image_checksum
vm_params["start_job"] = 'vectorize'
vm_params["image_type"] = image.image_type if image.image_type != 'none'
vm_params["image_complexity"] = image.image_complexity if image.image_complexity != 'none'
vm_params["image_num_colors"] = image.image_num_colors if image.image_num_colors != ''
vm_params["image_colors"] = image.image_colors if image.image_colors != ''
vm_params["expire_at"] = image.expire_at if image.expire_at != ''
vm_params["licensee_id"] = DEVELOPER_ID
#in php it's like this $vm_params["sequence_number"] = -rand(100000000);?????
vm_params["sequence_number"] = Kernel.rand(1000000000) # Use a negative value to force an error when calling the test server
vm_params["timestamp"] = Time.new.utc.httpdate
string_to_sign =
CREATE_URL + # Start out with the URL being called...
#vm_params["image"].to_s + # ... don't include the file per se - use the checksum instead
vm_params["image_checksum"].to_s + # ... then include all regular parameters
vm_params["start_job"].to_s +
vm_params["image_type"].to_s +
vm_params["image_complexity"].to_s + # (nil.to_s => '', so this is fine for vm_params we don't use)
vm_params["image_num_colors"].to_s +
vm_params["image_colors"].to_s +
vm_params["expire_at"].to_s +
vm_params["licensee_id"].to_s + # ... then do all the security parameters
vm_params["sequence_number"].to_s +
vm_params["timestamp"].to_s
vm_params["signature"] = sign(string_to_sign) #no problem
# Workaround class for handling multipart posts
mp = Multipart::MultipartPost.new
query, headers = mp.prepare_query(vm_params) # Handles the file parameter in a special way (see /lib/multipart.rb)
file.close # mp has read the contents, we can close the file now
response = post_form(URI.parse(CREATE_URL), query, headers)
logger.info(response.body)
response_hash = ActiveSupport::JSON.decode(response.body) # Decode the JSON response string
##I have understood below
def sign(string_to_sign)
#logger.info("String to sign: '#{string_to_sign}'")
Base64.encode64(HMAC::SHA1.digest(DEVELOPER_KEY, string_to_sign))
end
# Within Multipart modul I have this:
class MultipartPost
BOUNDARY = 'tarsiers-rule0000'
HEADER = {"Content-type" => "multipart/form-data, boundary=" + BOUNDARY + " "}
def prepare_query (params)
fp = []
params.each {|k,v|
if v.respond_to?(:read)
fp.push(FileParam.new(k, v.path, v.read))
else
fp.push(Param.new(k,v))
end
}
query = fp.collect {|p| "--" + BOUNDARY + "\r\n" + p.to_multipart }.join("") + "--" + BOUNDARY + "--"
return query, HEADER
end
end
end
Thanks for your help.
I don't know much about SSL, but I've read something and I was wondering if it's possible to intercept the communication between client and server (for example, a company can monitor employees data transfer?).
I thought it was a difficult task, but it looks like that it is very simple. When a client requests a https connection the router can be instructed to intercept the key exchange and send to the server and the client it's own public keys (further it can encode/decode the hole traffic).
Is it true, or I'm misunderstanding something?
Sorry for unclear description, my English is not good.
My problem is that I want to decode a string, and this string has nested content delimited by {}.
For example:
The string:
{any string0{any string 00{any string 000....}}}{any string1}any string.
The result I want to get:
array[0] = {any string0{any string 00{any string 000....}}}
array[1] = {any string1}
I hope it's clear enough.
Hi Everyone,
I'm calling a php file from Flash and adding variables afterwards like so:
http://www.randomwebsite.com/something.php?title=??
It works fine if I copy and paste this directly into the web browser, however if I call it through flash, the address bar would end up like this: something.php?title=??
Is there anything I can do from PHP or flash to encode/decode the string?
Any help is greatly appreciated.
Thanks,
Will
I have a need to search a pdf file to see if a certin string is present. The string in question is definately encoded as text (ie. it is not an image or anything). I have tried just searching the file as though it was plain text, but this does not work.
Is it possible to do this? Are there any librarys out there for .net2.0 that will extract/decode all the text out of pdf file for me?
Hey,
I'm having some issues trying to decode some javascript.. I have no idea what kind of encoding this is.. i tried base 64 decoders etc. If you can please help me out with this, here's a fragment of the code:
\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C","\x61\x70\x70\x34\x39\x34\x39\x3
Any ways I can get plain text from that?
Thanks!
I doubt if this is encryption but I can't find a better phrase. I need to pass a long query string like this:
http://test.com/test.php?key=[some_very_loooooooooooooooooooooooong_query_string]
The query string contains NO sensitive information so I'm not really concerned about security in this case. It's just...well, too long and ugly. Is there a library function that can let me encode/encrypt/compress the query string into something similar to the result of a md5() (similar as in, always a 32 character string), but decode/decrypt/decompress-able?
Hello,
.... ‹BÿЃÀ‰D$Ç„$ ....... that's what happens when you open (notepad) such a file that I'm talking about
How do algorithms decode that information and when does a program use/generate it ?
Does some notepad-like application exist that open such files and transform them to readable code/data ?
Any more information which will clarify about these files will be very helpful.
Thank you for your time,
P.S I'm not talking strictly about .exe files
this is my code:
print '??'.decode('gb2312').encode('utf-8')
and it print :
SyntaxError: Non-ASCII character '\xe5' in file D:\zjm_code\a.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
how to print '??'
thanks
I have an oracle query in which and i want the result to be in custom order 'SENIOR DIRECTOR', 'DIRECTOR', 'MANAGER', 'EMPLOYEE' which is from the field GRADE_DESCRIPTON. I am using the below query.
However I am not getting the desired result
The order of the result im getting is 'SENIOR DIRECTOR','MANAGER', DIRECTOR,'EMPLOYEE'
SELECT DISTINCT GRADE_DESCRIPTION, HIRING_FORECATS.* FROM GRADE_MASTER left join IRING_FORECATS ON (HIRING_FORECATS.GRADE = GRADE_MASTER.GRADE_DESCRIPTION and HIRING_FORECATS.LOCATION = 'HO' ) order by decode(GRADE_MASTER.GRADE_DESCRIPTION, 'SENIOR DIRECTOR', 'DIRECTOR', 'MANAGER', 'EMPLOYEE')
Any Suggestions??
I was developing a application that changes color image to gray image. However, some how the picture comes out wrong. I dont know what is wrong with the code. maybe the parameter that i put in is wrong please help.
UIImage *c = [UIImage imageNamed:@"downRed.png"];
CGImageRef cRef = CGImageRetain(c.CGImage);
NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef));
size_t w = CGImageGetWidth(cRef);
size_t h = CGImageGetHeight(cRef);
unsigned char* pixelBytes = (unsigned char *)[pixelData bytes];
unsigned char* greyPixelData = (unsigned char*) malloc(w*h);
for (int y = 0; y < h; y++) {
for(int x = 0; x < w; x++){
int iter = 4*(w*y+x);
int red = pixe lBytes[iter];
int green = pixelBytes[iter+1];
int blue = pixelBytes[iter+2];
greyPixelData[w*y+x] = (unsigned char)(red*0.3 + green*0.59+ blue*0.11);
int value = greyPixelData[w*y+x];
}
}
CFDataRef imgData = CFDataCreate(NULL, greyPixelData, w*h);
CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData(imgData);
size_t width = CGImageGetWidth(cRef);
size_t height = CGImageGetHeight(cRef);
size_t bitsPerComponent = 8;
size_t bitsPerPixel = 8;
size_t bytesPerRow = CGImageGetWidth(cRef);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGBitmapInfo info = kCGImageAlphaNone;
CGFloat *decode = NULL;
BOOL shouldInteroplate = NO;
CGColorRenderingIntent intent = kCGRenderingIntentDefault;
CGDataProviderRelease(imgDataProvider);
CGImageRef throughCGImage = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, info, imgDataProvider, decode, shouldInteroplate, intent);
UIImage* newImage = [UIImage imageWithCGImage:throughCGImage];
CGImageRelease(throughCGImage);
newImageView.image = newImage;
I doubt if this is encryption but I can't find a better phrase. I need to pass a long query string like this:
http://test.com/test.php?key=[some_very_loooooooooooooooooooooooong_query_string]
The query string contains NO sensitive information so I'm not really concerned about security in this case. It's just...well, too long and ugly. Is there a library function that can let me encode/encrypt/compress the query string into something similar to the result of a md5() (similar as in, always a 32 character string), but decode/decrypt/decompress-able?
Hi All,
I found this implementation, and i am not sure whether we can use this implementation and apple will bye-pass extra check, this is a base-64 implementation.
The source code link is
http://blog.objectgraph.com/wp-content/uploads/2010/04/CryptTest.zip
The web page link is : http://blog.objectgraph.com/index.php/2010/04/20/encrypting-decrypting-base64-encode-decode-in-iphone-objective-c/
Kindly advice me friends.
Hi
i am working on a web application where i have to encode and decode a string at the JavaScript side and ruby backend of the code. the only problem is that the escape methods for JavaScript and ruby have a small difference. in java script the " " is treated as "%20" but in ruby the " "(space) is encoded to "+".
any way to work around this? another ruby method to encode a string in RAW url encode?
thank you
I have tried using a data URI to load the image data into a movie clip, but flash lite does not appear to support the data URI scheme.
I also thought it might be possible to base64 decode the image data and write it out to a file and load the file back into the movie clip using the file URI scheme. However, I do not see a way to write to the filesystem in the documentation. Am I missing something in the flash lite docs that would allow me to write to the filesystem?
I wish to become a good specialist in image processing, for example I want to know how to find barcodes or car plates and so on, anything that i think about, an apple on image.
And then to do something more, for example decode the barcode or just write - this is an apple.
So do you know a good book or online course?
Given this example, I get the error that follows:
print u'\2033'.translate({2033:u'd'})
C:\Python26\lib\encodings\cp437.pyc in encode(self, input, errors)
10
11 def encode(self,input,errors='strict'):
---> 12 return codecs.charmap_encode(input,errors,encoding_map)
13
14 def decode(self,input,errors='strict'):
UnicodeEncodeError: 'charmap' codec can't encode character u'\x83' in position 0
i try to write this code to process Arabic language by python
import codecs
file = codecs.open("C:\Python27\CCA_raw_utf8.txt","r","utf-8")
text= file.read()
####################################
print "\n "," --------------------------------------------"
text=text[1:]
words=text.split()
for w in words:
if w == unicode ("?????","utf-8"):
print w
but it doesn't and take error " if w == unicode ("?????","utf-8"):
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc7 in position 0: invalid continuation byte "
why program gives this result and how we can correct that??
for st in Traks :
trak = TrakHtml()
trak.hawb = st
url = 'http://etracking.cevalogistics.com/eTrackResultsMulti.aspx?sv='+st
result = urlfetch.fetch(url)
trak.htmlData = result.content
trak.put()
trak.htmlData is a textproparty(). It's giving this error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 29284: ordinal not in range(128)
class sss(webapp.RequestHandler):
def get(self):
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
self.response.out.write(result.content)
and this view show :
when i change code to this:
if result.status_code == 200:
self.response.out.write(result.content.decode('utf-8').encode('gb2312'))
it show :
so ,what i should do ?
thanks
assume there are three group of high dimension vectors:
{a_1, a_2, ..., a_N},
{b_1, b_2, ... , b_N},
{c_1, c_2, ..., c_N}.
each of my vector can be represented as: x = a_i + b_j + c_k, where 1 <=i, j, k <= N. then the vector is encoded as (i, j, k) wich is then can be decoded as x = a_i + b_j + c_k.
my question is, if there are two vector: x = (i_1, j_1, k_1), y = (i_2, j_2, k_2), is there a method to compute the euclidian distance of these two vector without decode x and y.
Hi All,
I want to convert my text into HTML format, it would be just like this that I just copy paste the text from word, pdf [with formatting & colors] to the editor and it will convert it into HTML tags, so that when I decode it again it would give me the same format that I have pasted.
I am almost happy with the page brezeer but sometimes it destroy the formatting.
Please suggest me any other editor.
Thanks in advance
Hey,
I'm having some issues trying to decode some javascript.. I have no idea what kind of encoding this is.. i tried base 64 decoders etc. If you can please help me out with this, here's a fragment of the code:
\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C","\x61\x70\x70\x34\x39\x34\x39\x3
Any ways I can get plain text from that?
Thanks!