RSA : Encrypt in Javascript and Decrypt in Php - php

I've found many websites with something related to the subject line (few are in stackoverflow.com itself). However, unfortunately I couldnt get what I want.
What I want is - I've a public-private key pair ready with me. (something like this - http://andytson.com/blog/2009/07/php-public-key-cryptography-using-openssl/)
Now, I want a javascript page which will use this public key. And encrypt some data. This data is then passed on to the php page. And the php page decrypts the data.
So far, I've found few JS pages which does this stuff right from the scratch (i.e. from generating the key pair). Same story for php. But thats not of help to me.
Any help is highly appreciated.
Cheers

Does http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=33024&start=0 do what you're wanting? Here's the stand-alone demo:
http://www.frostjedi.com/terra/dev/rsa/index.php
The source:
http://www.frostjedi.com/terra/dev/rsa/index.txt

Related

Decrypt/Decipher text

Good Day!
This is my first time to ask question here in stackoverflow, cause usually I only read the solutions that has similar problem with mine. So my problem is, I had been given a task to decipher/decrypt the content of an excel file. (By the way i'm using PHP Language). I queried many times the encyrpt/decrypt on google but still failed. What I found somewhat related (well i guess the nearest solution here) is the base64_encode and base64_decode. To explain more this is my sample encrypted sentence (sentence because it should be resulted as a question)
V1JSeEhUUDJiaVdrZmJYSllxV3h2K3B1eDZYY2xobEM4QVRBTDhiTEVkU3JGVHVnelZWUUdWNGNyeGVGYXdrQU9DdXV2cFg4SkcxRzBJblRjY2E4SXh4Q21tNXNVZExrUVZFVDF0SFRXMGFTdms3ZTF5NlkvWXhCd2lkbHhBKzhRaSt5MlpzSC9KRVhNa2pZSXFIcnZBPT0=
I tried the code
$str = "V1JSeEhUUDJiaVdrZmJYSllxV3h2K3B1eDZYY2xobEM4QVRBTDhiTEVkU3JGVHVnelZWUUdWNGNyeGVGYXdrQU9DdXV2cFg4SkcxRzBJblRjY2E4SXh4Q21tNXNVZExrUVZFVDF0SFRXMGFTdms3ZTF5NlkvWXhCd2lkbHhBKzhRaSt5MlpzSC9KRVhNa2pZSXFIcnZBPT0=";
base64_decode($str);
The Result is:
81y7Vr6Xqh13qRf4/lWLYMVtim98/w5Y6aNegV4FmbWwpHonakWSigYgN928ksjBdsTff1lSVIGQchQnoV5S8Mw0IIszCSUe2+QxHdJ6X875pS52vReRZcBKHmnN5uFH
Which is wrong because it should display a more readable words/sentence. I don't know if I'm just missing anything. Any advice will be greatly appreciated. Thank you in advance!
PS: I tried the online bsae64 decoder (https://www.base64decode.org/) and it displays the right words like Man -> TWfu (vice versa) so I don't know if I'm focusing on a wrong solution or syntax.
You need to be sure about the encryption algorithm used on the file. If it is encrypted using AES, you might want to know the key.
Apparently an AES, or a Blowfish block. Having the key would be helpful.

Need advice about making a forum with php

I am trying to create a forum on my page. I need some advice. I have MySQL database and I am able to to work with it. Yet as far as I can make is playing with POST. I mean on click submit a $_POST['submit']) becomes set and so on. Then connect to database, get info and display.This way of making a forum is bad, because it all happens on a single page. As far as I seen any other forum when entering one and so on has it's unique Uri (what comes after domain.com/) so you can simply send someone full url and they are in that thread (unlike if you play with $_POST['submit']).
Sorry if my question is not accurate and I am not asking to write me code. I just need someone to direct me to the right place and any advice would be helpful. Thanks !
Your question is difficult to understand, but I think you are confused about how data and pages are dynamic using GET/POST.
The URLS with different IDs are like an illusion. Really, its the same page, however the page is dynamically taking that ID from the URL, and using it to output certain data.
For example, say we habe the URL: www.example.com/show_thread.php?thread=3
The php would look like
if(isset($_GET['thread'])){
$data = $db>query("SELECT thread_title,thread_text FROM threads WHERE thread_id = $_GET['thread']");
print($data);
}
*Warning: do not use this exact code, it is an example, not secure, etc
Then the database would look like
thread_id thread_title thread_text
1 kngwihywoihwy kngwihywoihwykngwihywoihwy
2 vyfngoieyoiehyon ieonuwrtoi hunwrmt jirwyji
3 nuoaiefguneoihn eoithneiotheo
and the page would show
nuoaiefguneoihn eoithneiotheo
POSTing data is for sending it to the server, and doing something with it. Just like GET. However, GET is helpful for passing things around as they are accessible in links. Like this example.

API Integration with website

i have been assigned to integrate an API in a blog.
API URL:http://www.ask-oracle.com/charts/api.php?dt=2015-10-19T08%3A48%3A32%2B05%3A30
I am able to get the data using
$data = file_get_contents('http://www.ask-oracle.com/charts/api.php?dt=' .$date .'T08%3A48%3A32%2B05%3A30');
But not able to organize it properly.
It returned JSON array, i need your help in getting out the data and show properly(organized way) in my blog.
Please help me, how i can do it.
I will be very thankful to you if you provide me code(in html or php) also.
This is up to you to decide how to organize this. As #steve suggested it, you should convert the JSON stream to a PHP object, and then transform it to HTML to "organize" it for humans who are not able to read JSON. It will surely also involve CSS.
If somebody asked you this work but didn't gave more informations about how to display it and you have no idea about how to do it, you should maybe ask for more precise specifications before starting the work.
Note that saying that JSON is not properly organized is not exact. JSON is a structured data notation.

Pull facebook data xml

http://developers.facebook.com/docs/reference/rest/links.getStats/
Okay I have looked at the site above. but im still having some trouble.
I have formated what I need like this
http://api.facebook.com/restserver.php?method=links.getStats&urls=dogtags.com.com,http://www.petsmart.com
My only issue is I need this data to be picked by the zip code another words I only want to see how many likes are on the url http://www.petsmart.com in the zip code 66614. How can I add that variable to the xml data displaying
Thank you all help is greatly appreciated
You are using an outdated facebook API. I would recommend implementing:
http://developers.facebook.com/docs/reference/api/insights/
However, I do not believe there is any way to to look at data from a specific zip-code using the facebook insight API

Grabbing reddit comments and archiving them in a database with php

so I know basic PHP, I coded a basic mysql/php inventory system awhile ago. I want to get more experience. My idea is to grab reddit comments, display them on a page, and then save them in a database. My problem is I don't know how to grab and make sense of JSON data.
For example, here is a JSON link to a reddit thread: http://www.reddit.com/r/blog/comments/117ckb/introducing_three_new_hires/.json
Goal:
INPUT BOX -> reddit unique thread id in input box (http://www.reddit.com/r/blog/comments/<6 digit unique ID>) -> loads reddit comments on the page
That's my current goal, would really appreciate a nudge in the right direction with processing JSON. I know I COULD just Google it, but I'm posting in hopes of someone having experience with the above and offering their expertise on the topic.
Here's a starting point:
$download=json_decode(file_get_contents('http://www.reddit.com/r/blog/comments/117ckb/introducing_three_new_hires/.json'));
foreach ($download as $articles){
foreach ($articles->data->children as $article){
print_r($article);
}
}
Please note: I recommend using Curl instead of get_file_contents() - it's a lot faster!

Categories