diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-24 10:32:08 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-24 10:32:08 -0700 |
commit | cb7b3b5cfb3d59e1e3210c6eeff8cb39e6830c8e (patch) | |
tree | faafbd59450afbe339f1a9b017c42a93face4e44 | |
parent | 83c137c45b02652d4d14f7bd48f43b218f57ad47 (diff) | |
download | jp-hash-cb7b3b5cfb3d59e1e3210c6eeff8cb39e6830c8e.tar.gz jp-hash-cb7b3b5cfb3d59e1e3210c6eeff8cb39e6830c8e.tar.bz2 jp-hash-cb7b3b5cfb3d59e1e3210c6eeff8cb39e6830c8e.zip |
README: add details to spec.
* README.md: Specify the details of the seven cases
of combining the pieces into the output result, instead
of referring to the implementation.
-rw-r--r-- | README.md | 78 |
1 files changed, 48 insertions, 30 deletions
@@ -33,42 +33,60 @@ providing a simple UI. ## What are the details of the algorithm? -1. First, the input is hashed via the standard SHA256 sum. +1. First, the input is hashed via the standard SHA256 sum. -2. Next, the first 18 bytes of the digest are interpreted as an array of 9 - (nine) 16-bit words, little endian. This array is referred to as `word[0]` - through `word[8]`. +2. Next, the first 18 bytes of the digest are interpreted as an array of 9 + (nine) 16-bit words, little endian. This array is referred to as `word[0]` + through `word[8]`. -3. Six pseudo-Japanese syllables are derived from `word[0]` through `word[5]` - as follows: each of these word values is reduced to the remainder modulo 97. - Then, the remainder is used as an index into the following array of 97 - strings. The first letter of the first syllable is then capitalized. +3. Six pseudo-Japanese syllables are derived from `word[0]` through `word[5]` + as follows: each of these word values is reduced to the remainder modulo 97. + Then, the remainder is used as an index into the following array of 97 + strings. The first letter of the first syllable is then capitalized. + These syllables are here referred to as `sy[0]` through `sy[5]`. -``` -["a", "i", "u", "e", "o", "ya", "yu", "yo", "wa", - "ka", "ki", "ku", "ke", "ko", "ga", "gi", "gu", "ge", "go", - "sa", "shi", "su", "se", "so", "za", "ji", "zu", "ze", "zo", - "ta", "chi", "tsu", "te", "to", "da", "de", "do", - "na", "ni", "nu", "ne", "no", "ha", "hi", "fu", "he", "ho", - "pa", "pi", "pu", "pe", "po", "ba", "bi", "bu", "be", "bo", - "ma", "mi", "mu", "me", "mo", "ra", "ri", "ru", "re", "ro", - "kya", "kyu", "kyo", "gya", "gyu", "gyo", "sha", "shu", "sho", - "ja", "ju", "jo", "cha", "chu", "cho", "nya", "nyu", "nyo", - "hya", "hyu", "hyo", "pya", "pyu", "pyo", "bya", "byu", "byo", - "mya", "myu", "myo", "rya", "ryu", "ryo"] -``` + ["a", "i", "u", "e", "o", "ya", "yu", "yo", "wa", + "ka", "ki", "ku", "ke", "ko", "ga", "gi", "gu", "ge", "go", + "sa", "shi", "su", "se", "so", "za", "ji", "zu", "ze", "zo", + "ta", "chi", "tsu", "te", "to", "da", "de", "do", + "na", "ni", "nu", "ne", "no", "ha", "hi", "fu", "he", "ho", + "pa", "pi", "pu", "pe", "po", "ba", "bi", "bu", "be", "bo", + "ma", "mi", "mu", "me", "mo", "ra", "ri", "ru", "re", "ro", + "kya", "kyu", "kyo", "gya", "gyu", "gyo", "sha", "shu", "sho", + "ja", "ju", "jo", "cha", "chu", "cho", "nya", "nyu", "nyo", + "hya", "hyu", "hyo", "pya", "pyu", "pyo", "bya", "byu", "byo", + "mya", "myu", "myo", "rya", "ryu", "ryo"] + +4. A digit `dig` is chosen using the modulo 10 remainder of `word[6]` as an + index into the digits `0` through `9`. + +5. Similarly, a symbol `sym` is chosen using the modulo 10 remainder of + `word[7]` as an index into the aforementioned list `!`, `#`, `@`, `$`, `%`, + `^`, `&`, `*`, `?` and `/`. + +6. The modulo 8 value of `word[8]` is used to select eight cases (0 to 7) for + combining the above values into an output string. The last four of these + cases insert the `n` (letter n) character into certain places of the string. + The eight cases follow: each case give a list of strings which are + catenated in that order, with no intervening spaces or other separator + characters: + + **Case 0**: `s[0] s[1] s[2] sym s[3] s[4] s[5] dig` + + **Case 1**: `sym s[0] s[1] s[2] dig s[3] s[4] s[5]` + + **Case 2**: `s[0] s[1] sym s[2] s[3] dig s[4] s[5]` + + **Case 3**: `s[0] s[1] dig s[2] s[3] sym s[4] s[5]` + + **Case 4**: `s[0] s[1] s[2] "n" sym s[3] s[4] s[5] dig` + + **Case 5**: `sym s[0] s[1] s[2] dig s[3] s[4] s[5] "n"` -4. A digit is chosen using the modulo 10 remainder of `word[6]` as an index - into the digits `0` through `9`. + **Case 6**: `s[0] s[1] "n" sym s[2] s[3] dig s[4] s[5]` -5. Similarly, a symbol is chosen using the modulo 10 remainder of `word[7]` as - an index into the aforementioned list `!`, `#`, `@`, `$`, `%`, `^`, `&`, - `*`, `?` and `/`. + **Case 7**: `s[0] s[1] dig s[2] s[3] sym s[4] s[5] "n"` -6. The modulo 8 value of `word[8]` is used to select eight cases (0 to 7) for - combining the above values into an output string. The last four of these - cases insert the `n` (letter n) character into certain places of the string. - The details are in the reference implementation. ## How many JP-Hash digests are there? |