Click here to Skip to main content
15,887,302 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
It's part of a larger exercise that consists in encrypting a message with the Caesar code.

The goal is to find the longest word. the longest word will then be the number of letters used for the Cesar code shift.

What I have tried:

PHP
function cmp($str1, $str2) {
    $length1 = strlen($str1);
    $length2 = strlen($str2);

    if ($length1 == $length2)
        return 0;

    return ($length1 < $length2) ? -1 : 1;
}
Posted
Updated 19-Aug-22 23:08pm

1 solution

Ignoring that Caesar Cypher isn't encryption at all, it's a basic translation which is regularly cracked by grandmothers from a monthly magazine fool of them ...

That compares two string lengths: you pass it two strings, if they are the same length it returns 0, if the first is shorter it returns -1, otherwise 1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900