DEV Community

Cover image for Banana encryption: Decoding Caesar Cipher with Power Automate
Bala Madhusoodhanan
Bala Madhusoodhanan

Posted on

9 1 1 1 2

Banana encryption: Decoding Caesar Cipher with Power Automate

Intro:
Lets dive on mischievous world of Minions and the ancient art of encryption. Julius Caesar, the original mastermind behind a secret language Caesar cipher. It encrypts letters by shifting them over by a certain number of places in the alphabet. We call the length of shift the key. For example, if the key is 3, then A becomes D, B becomes E, C becomes F, and so on.

Logic:
The process of encrypting messages in Power Automate involves taking the user's input message and a secret key. Initially, the user's message is converted to uppercase, and the length of the secret key is recorded for subsequent steps.

toUpper(triggerBody()['text'])
Enter fullscreen mode Exit fullscreen mode

To execute the encryption, a scale or array is necessary, containing all the alphabets, spaces, and numbers. A new variable is introduced to iterate through each character of the user's message and offset it based on the key length.

length(triggerBody()['text_1'])
Enter fullscreen mode Exit fullscreen mode

To facilitate the offset process, the user's message is divided into an array of characters using the Chunk function.

chunk(outputs('UsrInput'),1)
Enter fullscreen mode Exit fullscreen mode

The offset logic consists of two main steps. First, the index of each character in the user's message is found against the fixed list of characters.

indexof(outputs('Alphastring'),items('Apply_to_each'))
Enter fullscreen mode Exit fullscreen mode

Subsequently, the lookup is offset by the length of the character

chunk(outputs('Alphastring'),1)[add(outputs('GetIndex'),outputs('Key'))]
Enter fullscreen mode Exit fullscreen mode

The final step involves appending the variable after each character is successfully offset, completing the encryption process.

Demo:

Encrypt

User Input Key Encrypt Output
"Good Morning " CAT JRRG2PRUQLQJ2
"Good Morning" CAT JRRG2PRUQLQJ
"Good Morning" encrypt NVVK6TVYUPUN

I hope you had a good time learning about encryption and how to use Power Automate for it. Happy coding!

Google AI Education track image

Work through these 3 parts to earn the exclusive Google AI Studio Builder badge!

This track will guide you through Google AI Studio's new "Build apps with Gemini" feature, where you can turn a simple text prompt into a fully functional, deployed web application in minutes.

Read more β†’

Top comments (3)

Collapse
 
leroyleow profile image
Leroy Leow β€’

Awesome write up on caesar cipher. Will love to give it test run on power automate

Collapse
 
wyattdave profile image
david wyatt β€’

The cool things you can do with power automate 😎

Collapse
 
balagmadhu profile image
Bala Madhusoodhanan β€’

Thank you for inspiring me !!!

Google AI Education track image

Build Apps with Google AI Studio 🧱

This track will guide you through Google AI Studio's new "Build apps with Gemini" feature, where you can turn a simple text prompt into a fully functional, deployed web application in minutes.

Read more β†’

πŸ‘‹ Kindness is contagious

Take a moment to explore this thoughtful article, beloved by the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A heartfelt "thank you" can brighten someone's dayβ€”leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay