user2452250
user2452250

Reputation: 797

Generate encrypted string with php, decrypt with javascript

I have a string, this string needs to be Encoded using PHP. Then its sent to a site via GET and needs to be decoded on this site via Javascript.

Its totally ok that somebody can decode the string, but I need that nobody is able to generate a new encoded string.

Basically, everybody should be able to decode the string without any problems, but nobody should be able to encode a new string.

Lets make a example for explanation:

My string is "hello world" and encrypt it SOMEHOW and get "asdflpausoiwjuh" as result. Then I send this result to you guys and you know how to decrypt it to read the message. but nobody of you is able to make a new message that can be encrypted in the same way.

MUST:

EDIT: The encrypted text has a validity of about an hour and tehre will actually not be real interest to "crack" the system. so security is not my priority. what i really need is that 99% of the people wont be able to generate the string, and the 1% should have a hard time figuring out how to do it. for me that is safe enough. my problem is that whatever i think of putting into the javascript code, brings me to something that can be reverse engeneered.

Upvotes: 0

Views: 226

Answers (1)

Norwæ
Norwæ

Reputation: 1575

You might look into some entry-level explanation of public key cryptography. What you intend to do is a classical example, only in reverse. ;)

Most likely what you really want to do is sign a message. That means, you want to make sure any message comes from you and only you. Its public and needs not be encrypted, but you want recipients to know it was not altered in transit.

Here's a link to get you started:

http://en.wikipedia.org/wiki/Digital_signature

Upvotes: 2

Related Questions