Files
herolib/lib/crypt/secrets/encrypt_decrypt.v
2025-10-12 12:30:19 +03:00

22 lines
533 B
V

module secrets
import rand
import incubaid.herolib.ui.console
import incubaid.herolib.ui
import incubaid.herolib.crypt.aes_symmetric
import crypto.md5
import regex
import os
import encoding.base64
// will use our secret as configured for the hero to encrypt
pub fn (mut b SecretBox) encrypt(txt string) !string {
d := aes_symmetric.encrypt_str(txt, b.secret)
return base64.encode_str(d)
}
pub fn (mut b SecretBox) decrypt(txt string) !string {
txt2 := base64.decode_str(txt)
return aes_symmetric.decrypt_str(txt2, b.secret)
}