0

Hey, I'm a beginner programmer and have been grinding my teeth over this one specific part of my program for hours and have finally admitted to myself that I need help.

Here's the problem:
I have to write an encryption function that is simply the sum of the unicode values of all the letters in a word, multiplied by the product of the unicode values of the FIRST FIVE letters in the word, modulus 1459303249. The words below are what I was given to check that my function was working properly.

  • hello : 1205468819
  • goodbye : 312635099
  • hello27 : 502523728
  • eybdoog : 1200983286

Here's what I've tried so far:
(this I used just to test & make sure the word "hello" would come out to the right number):

long a = ('h' + 'e' + 'l' + 'l' + 'o') * ('h' * 'e' * 'l' * 'l' * 'o')% 1459303249;

It returned a huge, negative number. I have a feeling that I'm mixing things up or otherwise overlooking something simple. Any tips would be greatly appreciated!!

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by iamthwee
0

I think it would be more intutive to create a function such as:

if a
 then unicode = 97
end if

if b 
  then unicode = 98
endif

And then to separate your string into chars using the function tochar().

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.