I know I shouldn't be answering this as it is off topic but there are things that must be cleared here:
"Encoding" data
In your first paragraph, you said I am encoding the entered data, I don't know what you mean exactly by that.
If you mean encryption, I'm not sure how are you encrypting e-mails/username if you use them for authentication.
But generally speaking, encrypting data is a good thing as long as you are using a good cipher with a strong securely stored key, check Where to store a server-side encryption key?.
You also said using sha1 before storing it in the database. This is also unclear, are you hashing all data with sha1? if so. how do you "unhash" the data when you need it.
I suppose you are hashing passwords, but sha1 and md5 (two common algorithms) are not suitable for passwords (or as @Peter said: unsuitable for anything security related).
To hash passwords, you need to use the right algorithms for that such as bcrypt, scrypt or argon.
In PHP, the best way to hash a password is by using the native built-in functions. password_hash()
for hashing and password_verify()
for verifying the hash.
These functions are available in PHP 5.5 or newer, if you use an older version - consider updating - you can use this compatibility library by ircmaxell.
Data "leakage"
In the 2nd paragraph, you talked about data submitted in a form being "leaked", I suppose you mean intercepted a.k.a. Man-In-The-Middle attack -MITM for short-.
To protect data from MITM attacks, you need to use HTTPS instead of the insecure HTTP.
HTTPS encrypts the data sent between your server and the client (browser/user) which will prevent anyone from intercepting the data.
Usually to get HTTPS you have to pay, but now there is a free Certificate Authority -CA for short- called Let's Encrypt that provides free certificates.
Encrypting data using JavaScript
You talked about encrypting data using JavaScript before submitting the form.
That wouldn't work simply because, when the client connects to your normal HTTP website, the HTML/JavaScript is in plain-text and can be changed, the attacker can simply intercept your JavaScript code (the one that will encrypt the data) and change it to whatever he wants.
The only solution you should consider is getting an SSL certificate for your website.
NSA thing
I assume that you are talking about the surveillance done by the agency, there are two things here:
MITM attack Which I already covered above, use HTTPS.
Accessing data on your server. If the NSA is somehow interested in your data, and your server is in a place where they have jurisdiction over, they can simply access the unencrypted data in your server.
Wrong terms you use
I see that you are miss-using the terms, encoding is not what you think.
Encoding is just transforming the data into a specific format (say JSON for example).
Encryption is when you take data and transform it to an unreadable format using an algorithm and a secret key, encryption protects the data from unauthorized access, encrypted data can be decrypted to its original state.
Hashing is generating a value (called a hash) from given data using a one-way function.
Which means, given a hash you can't theoretically get the original value back.
This is just a general answer to your question and not an ultimate security guideline (I'm not a security expert!)
References