This challenge is about making a basic user interface to present asymmetric cryptography.
You will only edit the code in src/app directory and optionally
package.json if you want to install packages, but you should not
need it.
You can develop on your locale machine or right in GitPod:
https://gitpod.io/#https://github.com/OVNICap/ReactTest
The interface contains 4 <textarea> inputs:
- Pass phrase
- Message
- Encrypted message
- Decrypted message (read-only)
You are also provided 3 async functions that wrap openpgp
functions and avoid you to deal with cryptographic configuration,
ease testing and gives you handy shortcuts designed for this
test:
function generateKey(passPhrase: string): Promise<KeyPair>
function encrypt(message: string, publicKeyArmored: string): Promise<string>
function decrypt(encryptedMessage: string, privateArmoredKey: string, passPhrase?: string): Promise<string>KeyPair contains the following:
privateKeyArmored: string;
publicKeyArmored: string;Which gives the needed pair for asymmetric cryptography.
You can find them in src/lib but you don't need to modify them.
Here are the expected behaviors for the interface we wish you to develop:
- On
Pass phrasevalue change, callsawait generateKey(passPhrase)to generate a new key stored in the state of theAppcomponent. - During the key generation (which is asynchronous),
MessageandEncrypted messageinputs should bedisabled. - On
Messagevalue change, callsawait encrypt(message, publicKeyArmored)to encrypt the message and dump the result into the next field (Encrypted message) - On
Encrypted messagevalue change (rather it's a user input or indirect change due toMessagevalue change), callsawait decrypt(encryptedMessage, privateArmoredKey, passPhrase)- If decryption succeed, the result should be output in the next field
(
Decrypted message) and theDecrypted messagefield should also take the classsuccessso it becomes green. - If decryption thrown an error, the
Decrypted messagefield value should not change, but it should take the classfailureso it becomes red. - During the decryption which is asynchronous the
Decrypted messagefield should have no classes (neithersuccessnorfailure).
- If decryption succeed, the result should be output in the next field
(
In the project directory, you can run:
First you'll need to install the project dependencies using yarn or npm. (It will be ran automatically if using GitPod.)
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
If all the tests are passing, it means your interface meets the expectations.
When you're satisfied by your solution, zip the src/app folder
(with other files you modified if you did) and send it back to us
by e-mail.