describe('iD.utilAes', function() {

    it('encrypting and decrypting nothing yields nothing', async () => {
        expect(await iD.utilAesEncrypt('')).toEqual('');
        expect(await iD.utilAesDecrypt('')).toEqual('');
    });

    it('encrypts and decrypts with default key', async () => {
        var text = 'Hello iD!';
        var encrypted = '5597506f958c68543c';
        expect(await iD.utilAesEncrypt(text)).toEqual(encrypted);
        expect(await iD.utilAesDecrypt(encrypted)).toEqual(text);
    });

    it('encrypts and decrypts with a custom 16-bit key', async () => {
        var key = [
            216, 159, 213, 140, 129,  75,  80, 121,
             67, 201, 179, 120,  71, 237, 185,  42
        ];
        var text = 'Hello iD!';
        var encrypted = '9ff50e32b04f86640a';
        expect(await iD.utilAesEncrypt(text, key)).toEqual(encrypted);
        expect(await iD.utilAesDecrypt(encrypted, key)).toEqual(text);
    });

    it('encrypts and decrypts with a custom 24-bit key', async () => {
        var key = [
            180, 138, 124,  87, 157, 23, 209, 147,
             64,  65,  68, 206, 212, 79, 215, 114,
             37,  18, 159,  94, 168, 68, 177, 202
        ];
        var text = 'Hello iD!';
        var encrypted = '85fc05011fa7848417';
        expect(await iD.utilAesEncrypt(text, key)).toEqual(encrypted);
        expect(await iD.utilAesDecrypt(encrypted, key)).toEqual(text);
    });

    it('encrypts and decrypts with a custom 32-bit key', async () => {
        var key = [
              4,  48, 130, 253, 213, 139, 96,  178,
            170, 108, 127, 233, 167, 137, 181,  41,
            145,  62, 251,   9,  82, 159, 103, 198,
             63, 200, 158, 104, 188,  77, 193,  16
        ];
        var text = 'Hello iD!';
        var encrypted = '13c21d3dc25165c57c';
        expect(await iD.utilAesEncrypt(text, key)).toEqual(encrypted);
        expect(await iD.utilAesDecrypt(encrypted, key)).toEqual(text);
    });
});
