Finding If Two string Are cipher of each other?

HELP,

i want to find if two input string are cipher of each other or not ?

inputstring 1 - “listen”
inputstring 2 - “silent”

so this both strings are cipher of each other ( so if we rearange the string 1 it becomes “silent” and vice versa

inputstring 1 - “hello”
inputstring 2 - “world”

and this strings are not cipher

so how to code that im confused.

Hi,

Do you mean anagram?
If so, the following will help you.

String.Concat(str1.OrderBy(Function(c) c))=String.Concat(str2.OrderBy(Function(c) c))

Regards.

1 Like

Hi @Ankit2

Try this

Str1="Silent"
Str2="Listen"
Anagram=String.Join("", str1.ToLower().OrderBy(Function(c) c)).Equals(String.Join("", str2.ToLower().OrderBy(Function(c) c)))
If
  Anagram
Then
   Log Message: Both strings are cipher to each other
Else
   Log Message: Both Strings are not cipher to each other

Hope it helps

1 Like

Thank you so much It worked

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.