Angular 19 Encreption in Angular not working

Discussão em 'Angular' iniciado por Guy Gallant, Março 21, 2025.

  1. Guy Gallant

    Guy Gallant Guest

    I am getting a strange error: TypeError: this.ConvertToIvClass is not a function @Injectable({ providedIn: 'root' })
    export class JwtEncreptionService { constructor() {} encrypt(value: string, generic: string): string { if (generic === 'SKIP') return '';

    let first16 = generic.substring(0,16); // Key 1203199320052021
    let snd16 = generic.substring(16,32); // Iv 2203199320052031

    let _key = CryptoJS.enc.Utf8.parse(first16);
    let _iv = CryptoJS.enc.Utf8.parse(snd16);

    let results = '';
    try {
    results = CryptoJS.AES.encrypt(value, _key,{iv: _iv,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7,
    }).toString();
    }
    catch(e) {
    console.log(e);
    }
    return results;
    }


    I cannot find any documentation regarding this error. This function is withing a serverice which is injected) Any advice would be very helpful

    Continue reading...

Compartilhe esta Página