|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "strings" |
| 6 | +) |
| 7 | + |
| 8 | +func encode(text string) string { |
| 9 | + encodingMap := map[string]string{ |
| 10 | + "a": ";EDDAI", "b": ";FROCIO", "c": ";skks", "d": ";stocazzum", "e": ";miau", |
| 11 | + "f": ";gatto", "g": ";shell", "h": ";cazzarola", "i": ";azzo", "j": ";bau", |
| 12 | + "k": ";MaNonLoSoHoFinitoLeParoleRandomicheDaMettere", "l": ";gronc", "m": ";releone", |
| 13 | + "n": ";fuckmepls", "o": ";milliseconds", "p": ";mare", "q": ";lago", "r": ";straykids", |
| 14 | + "s": ";alfabeto", "t": ";droga", "u": ";eldenring", "v": ";hollowknight", "w": ";hollow", |
| 15 | + "x": ";yz", "y": ";gattinibellissimi", "z": ";sigmeyer", |
| 16 | + |
| 17 | + "A": ";elikoper", "B": ";JELIKOPETER", "C": ";wlattrocca", "D": ";wigattini", "E": ";hex", |
| 18 | + "F": ";GGH", "G": ";Lll", "H": ";miuwww", "I": ";motard", "J": ";patate", |
| 19 | + "K": ";figosaLaCappa", "L": ";nonsoaltreparolepercodificare", "M": ";pippo", "N": ";PippoBaudo", |
| 20 | + "O": ";letteraStramba", "P": ";pIsForPoppe", "Q": ";quaderno", "R": ";baubaubaumiao", |
| 21 | + "S": ";StandsForStrunz", "T": ";voglioungatto", "U": ";wleCANNE", "V": ";FR", |
| 22 | + "W": ";ProtocolloTCP", "X": ";mutande", "Y": ";hofinitoleparole", "Z": ";eStatoUnPartoTirareCosiTanteParoleRandomiche", |
| 23 | + |
| 24 | + " ": "_", "=": ";FUNZIONA", ".": ";DAJECAZZOVAI", "[": ";LeonardoEGAY", "]": ";TantoGay", |
| 25 | + ":": ";Gayone", ";": ";<>", "!": ";HoFinitoLeIdeeLOL", "|": ";QuantiCaratteriMancano?", |
| 26 | + "$": ";NonStoDelirandoGiuro", "#": ";OkayForse", "'": ";CreareStaCodifica_èStataUnaSfida", |
| 27 | + "\"": ";UnaSfidaControLaMiaSaluteMentaleLOL", "/": ";SoRetardato", "\\": ";WlaFiga", |
| 28 | + "<": ";boh_nonSoCheScrivere", ">": ";meowMEOW_BITCH", ")": ";miuw", "(": ";alfa", |
| 29 | + "&": ";SIUMTATTICOSO", "%": ";NoAllAlcolismo", |
| 30 | + |
| 31 | + "1": ";KkA", "2": ";aAa", "3": ";hhH", "4": ";meOWWWWWW", "5": ";AAAAAAAA", |
| 32 | + "6": ";SEX", "7": ";SIVENSTEVEN", "8": ";NumberOfStrayKids", "9": ";CazzumNine", |
| 33 | + "0": ";PaliNonPresiDaLeonardo", |
| 34 | + } |
| 35 | + |
| 36 | + var encodedText strings.Builder |
| 37 | + |
| 38 | + for _, char := range text { |
| 39 | + if encoded, found := encodingMap[string(char)]; found { |
| 40 | + encodedText.WriteString(encoded) |
| 41 | + } else { |
| 42 | + encodedText.WriteRune(char) |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + return encodedText.String() |
| 47 | +} |
| 48 | + |
| 49 | +func decode(encodedText string) string { |
| 50 | + decodingMap := map[string]string{ |
| 51 | + ";EDDAI": "a", ";FROCIO": "b", ";skks": "c", ";stocazzum": "d", ";miau": "e", |
| 52 | + ";gatto": "f", ";shell": "g", ";cazzarola": "h", ";azzo": "i", ";bau": "j", |
| 53 | + ";MaNonLoSoHoFinitoLeParoleRandomicheDaMettere": "k", ";gronc": "l", ";releone": "m", |
| 54 | + ";fuckmepls": "n", ";milliseconds": "o", ";mare": "p", ";lago": "q", ";straykids": "r", |
| 55 | + ";alfabeto": "s", ";droga": "t", ";eldenring": "u", ";hollowknight": "v", ";hollow": "w", |
| 56 | + ";yz": "x", ";gattinibellissimi": "y", ";sigmeyer": "z", |
| 57 | + |
| 58 | + ";elikoper": "A", ";JELIKOPETER": "B", ";wlattrocca": "C", ";wigattini": "D", ";hex": "E", |
| 59 | + ";GGH": "F", ";Lll": "G", ";miuwww": "H", ";motard": "I", ";patate": "J", |
| 60 | + ";figosaLaCappa": "K", ";nonsoaltreparolepercodificare": "L", ";pippo": "M", ";PippoBaudo": "N", |
| 61 | + ";letteraStramba": "O", ";pIsForPoppe": "P", ";quaderno": "Q", ";baubaubaumiao": "R", |
| 62 | + ";StandsForStrunz": "S", ";voglioungatto": "T", ";wleCANNE": "U", ";FR": "V", |
| 63 | + ";ProtocolloTCP": "W", ";mutande": "X", ";hofinitoleparole": "Y", ";eStatoUnPartoTirareCosiTanteParoleRandomiche": "Z", |
| 64 | + |
| 65 | + "_": " ", ";FUNZIONA": "=", ";DAJECAZZOVAI": ".", ";LeonardoEGAY": "[", ";TantoGay": "]", |
| 66 | + ";Gayone": ":", ";<>": ";", ";HoFinitoLeIdeeLOL": "!", ";QuantiCaratteriMancano?": "|", |
| 67 | + ";NonStoDelirandoGiuro": "$", ";OkayForse": "#", ";CreareStaCodifica_èStataUnaSfida": "'", |
| 68 | + ";UnaSfidaControLaMiaSaluteMentaleLOL": "\"", ";SoRetardato": "/", ";WlaFiga": "\\", |
| 69 | + ";boh_nonSoCheScrivere": "<", ";meowMEOW_BITCH": ">", ";miuw": ")", ";alfa": "(", |
| 70 | + ";SIUMTATTICOSO": "&", ";NoAllAlcolismo": "%", |
| 71 | + |
| 72 | + ";KkA": "1", ";aAa": "2", ";hhH": "3", ";meOWWWWWW": "4", ";AAAAAAAA": "5", |
| 73 | + ";SEX": "6", ";SIVENSTEVEN": "7", ";NumberOfStrayKids": "8", ";CazzumNine": "9", |
| 74 | + ";PaliNonPresiDaLeonardo": "0", |
| 75 | + } |
| 76 | + |
| 77 | + sortedKeys := make([]string, 0, len(decodingMap)) |
| 78 | + for key := range decodingMap { |
| 79 | + sortedKeys = append(sortedKeys, key) |
| 80 | + } |
| 81 | + // Sort keys by length descending |
| 82 | + sort.Slice(sortedKeys, func(i, j int) bool { |
| 83 | + return len(sortedKeys[i]) > len(sortedKeys[j]) |
| 84 | + }) |
| 85 | + |
| 86 | + decodedText := encodedText |
| 87 | + for _, key := range sortedKeys { |
| 88 | + decodedText = strings.ReplaceAll(decodedText, key, decodingMap[key]) |
| 89 | + } |
| 90 | + |
| 91 | + return decodedText |
| 92 | +} |
0 commit comments