id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-encryption > apcsaHashSumString
prev  |  next  |  chance

Given an input String, return the sum of all the numeric character values in the String. This will make use of the fact that char values are stored as numbers, which can be easily converted to int values. Note that this method can have any characters as inputs. Also, the numeric value of a char for this problem is not "adjusted" to begin with 'A'==1 like with Caesar ciphers: it is simply the numeric equivalent of the char itself.


This is one in a series of problems about cryptographic hash functions, which take in data of varying length and produce a smaller amount of data, often of a fixed length.  A cryptographic hash can be used to determine data integrity of a message, or even to determine whether a user knows a secret such as a password without actually knowing the secret yourself.  All the hash functions in these exercises are quite bad because they do not react strongly to small changes in input data, which should make them have wildly different results.  For more about cryptographic hashing try the following simplified explainer, or the more complex version.
https://simple.wikipedia.org/wiki/Cryptographic_hash_function
https://en.wikipedia.org/wiki/Cryptographic_hash_function
HINT
int a = str.charAt(0);

apcsaHashSumString("A") → 65
apcsaHashSumString("ABC") → 198
apcsaHashSumString("HI") → 145

...Save, Compile, Run (ctrl-enter)

public int apcsaHashSumString(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 310

Copyright Nick Parlante 2017 - privacy