i want to use aes128 in my game to encrypt match data and send it to backend(another server) api.
i did found aes128Encrypt method on nakama runtime framework. but It is not clear what is the cipher method and also the result is not a same every time method called!(and look like is not a base64 string!
1- the result is changes and also is not base64 every time that i calling the method!
To get a base64 encoded string output, you should use aesEncrypt instead.
You can see the implementation of the function here: nakama/server/runtime_javascript_nakama.go at v3.29.0 · heroiclabs/nakama · GitHub
The output of aesEncrypt should always be different even on the same input, because the IV value should be picked randomly. As you can see in the implementation, it is, and is prefixed to the output before the xor operation.
The Nakama aes API were really meant to be used to encrypt and decrypt the data from within Nakama, if you’d want to decrypt it elsewhere, you’d have to replicate the inverse steps of the implementation above.
I’d still advise you to just have the server behind HTTPs and cypher the data at rest, if needs be.