>>6109311Basically what
>>6109567 said. To be more precise, a mathematical function takes the text and transforms it into the tripcode (it's called a hashing function). The same text always makes the same code (because that's how maths works). 4chan adds some secret thing to the text before transforming it so that you can't compute them on your computer to steal them (it's called"salt" in crypto). For more info see Wikipedia
https://en.wikipedia.org/wiki/Imageboard#Tripcodes