generalpiston / typeorm-encrypted

Encrypted field for typeorm.
MIT License
74 stars 19 forks source link

generate key "Invalid key length" #23

Closed Paul75 closed 4 years ago

Paul75 commented 4 years ago

Hello,

When I generate key I see error : "Invalid key length"

I do for exemple :

export const MyEncryptionTransformerConfig = {
    key: Buffer.from(env.app.crypto.key, 'utf8').toString('base64'),
    algorithm: env.app.crypto.algorithm,
    ivLength: 16,
};

In env I add : env.app.crypto.key = nCM*R$izc*G3vqg7jo086mbc9Rg^7NYl

Thanks

Paul75 commented 4 years ago

Helllo,

Ok I see thant must generate key like :

const Crypto = require('crypto');
            return Crypto.randomBytes(32)
                .toString('hex')
                ;

Thanks

generalpiston commented 4 years ago

@Paul75 there are a lot of ways to generate keys...

Perhaps we should add this to the README.