# SceneLoader.RegisterPlugin decrypts cipher code of file in importMesh

**URL:** <https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449>\
**Category:** Questions\
**Created:** [November 6, 2022, 8:11pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449 "2022-11-06T20:11:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [November 6, 2022, 8:11pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449/1 "2022-11-06T20:11:30Z")

</div>

Hello,

I want to encrypt some _.babylon_ file with the _.ebabylon_ extension.

Then I would like to decrypt the files when ImportMesh is called.

I saw `BABYLON.SceneLoader.RegisterPlugin()` but I’m not sure how to use it to decrypt the code when ImportMesh is called.

I did the encryption and decryption functions (but I don’t understand how the RegisterPlugin works)

For the moment I did this as an example of what I want to do. It’s not supposed to work as is, it’s just for example and to know if I’m on the right track.  
I’m just trying to see if it’s doable.

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#D4C3UA%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [November 7, 2022, 12:07pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449/2 "2022-11-07T12:07:32Z")

</div>

Hey there!

RegisterPlugin basically just indexes the plugin object by its extension, so the SceneLoader will know to use it for later. To register a plugin, you’ll need it to extend ISceneLoaderPlugin [Babylon.js/sceneLoader.ts at master · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Loading/sceneLoader.ts#L192) or ISceneLoaderPluginAsync [Babylon.js/sceneLoader.ts at master · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Loading/sceneLoader.ts#L240). I put an example here that just uses the exising GLTFFileLoader plugin to do the work: [Test Register Plugin | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#7PEQSU#2)

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [November 7, 2022, 3:11pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449/3 "2022-11-07T15:11:15Z")

</div>

Thanks for the example. I will try to understand it.

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [November 8, 2022, 3:12pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449/4 "2022-11-08T15:12:41Z")

</div>

Ok, I didn’t understand how to use the registerPlugin.

I saw that you could use base64. so I did like this:

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#D4C3UA%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

1 I base64 encode the.babylon files and give them the ebabylon extension  
2 with ajax I will read the encode file and return the result  
3 I am using ImportMesh using `"data:;base64," +code`

And it works.

I would like to do the same with something other than base64 for the encoding. But it seems more complex than I thought.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [November 10, 2022, 8:54pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449/5 "2022-11-10T20:54:00Z")

</div>

Hi @Dad72,  
Here is a working example, in case you still want it

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#D4C3UA%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Cheers! 🍻

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [November 10, 2022, 10:29pm UTC](https://forum.babylonjs.com/t/sceneloader-registerplugin-decrypts-cipher-code-of-file-in-importmesh/35449/6 "2022-11-10T22:29:22Z")

</div>

Thank you very much MarianG. It’s better than what I had done, even though I had come up with a solution that worked.

Thanks again for your solution
