![]() |
CPSC 110-08: Computing on Mobile Phones
|
This app implements a simple cipher system that allows Alice and Bob to communicate "securely" using a shared secret key. The color-based Diffie-Hellman Key Exchange method is used to create the shared key. Messages are encrypted as strings of colors using a simple substitution cipher. Alice's and Bob's public keys are stored on a "public key server", implemented with a TinyWebDb. Messages are transmitted through the TinyWebDb.
Here's how it works:
Scroll down for additional details.
| Screenshot | QR Code | ![]() |
Android Package: ColorCrypto.apk |
|---|---|---|
| App Inventor Source Code: ColorCrypto.zip | ||
![]() | ||
To create a shared secret key, a Diffie-Hellman Key Exchange is performed by combining the sender's private key and the receiver's public key, both of which are 1 of the 16 million colors.
The secret key is used with a simple substitution cipher, in which letters of the alphabet are replaced by colors, using the following algorithms:
To encrypt (msg, key):
Set colorLst to empty_list
For each letter in msg:
Set color to shiftColorMod255( letterToNum(letter), key )
Add color to colorList
Return colorList
To decrypt (colorList, key):
Set msg to ""
For each color in colorList:
Set letter to numToLetter (reverseShiftColorMod255( color, key ) )
Add letter to msg
Return msg
The letterToNum() function maps 'a' to 0, 'b' to 1, etc., while the numToLetter performs the reverse mapping.
The shiftColorMod255(color1, color2) adds each color's RGB values mod 255, while the reverseShiftColorMod255(color1, color2) performs the reverse operation.