Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password encryption using google/tink

Good day, I have used google/tink to encrypt a password for storing in a DB using these steps :

// 1. Generate the key material.
KeysetHandle keysetHandle = 
    KeysetHandle.generateNew(AeadKeyTemplates.AES128_GCM);

// 2. Get the primitive.
Aead aead = AeadFactory.getPrimitive(keysetHandle);

// 3. Use the primitive to encrypt a plaintext,
byte[] ciphertext = aead.encrypt(plaintext, aad);

It basically converts password into the bytes, but when i convert it into string to store into the DB, It stores the encrypted password in this format : -�@~�k�D߶{׼�.

But i want to store the password in the format like 11As7737Cs9ue9oo09 using tink encryption.

Is there any way to do it?

like image 473
Manish Mehta Avatar asked Jan 03 '23 10:01

Manish Mehta


1 Answers

Manish, you might not want to encrypt the passwords. You want to hash them. Tink doesn't support password hashing yet, but we can add support if there's enough interest.

Could you please file for a feature request at https://github.com/google/tink/issues/new?

like image 67
Thai Duong Avatar answered Jan 14 '23 10:01

Thai Duong