<p>Looking through <a href="https://github.com/repetier/Repetier-Firmware" rel="nofollow noreferrer">the source</a> I found <a href="https://github.com/repetier/Repetier-Firmware/blob/master/src/ArduinoAVR/Repetier/Commands.cpp#L50" rel="nofollow noreferrer">Commands.cpp</a> that has a loop.</p>

<pre><code>void Commands::commandLoop() {
    while(true) {
        ...
        Commands::executeGCode(code);
    }
}
</code></pre>

<p>If we find the <a href="https://github.com/repetier/Repetier-Firmware/blob/master/src/ArduinoAVR/Repetier/Commands.cpp#L2395" rel="nofollow noreferrer">executeGCode</a> method, we see that it calls:</p>

<pre><code>processMCode(com);
</code></pre>

<p>And finding the <a href="https://github.com/repetier/Repetier-Firmware/blob/master/src/ArduinoAVR/Repetier/Commands.cpp#L860" rel="nofollow noreferrer">processMCode</a> method, we have the switch case you can add your own logic to.</p>

<pre><code>void Commands::processMCode(GCode *com) {
    switch( com-&gt;M ) {
        case 3: // Spindle/laser on
            ...

        case 999: // Your custom logic
</code></pre>

<p>After decoding your encrypted string, I think it would be best to call back into the first method mentioned, and let the process start from the top with the unencrypted command.</p>

<pre><code>case 999:

    // Custom logic
    executeGCode(unencrypted);
    break;
</code></pre>

CC BY-SA 3.0
2017-08-01T07:29:42.430Z
Thanks for the answer, Sorry for waiting for reply, I tried your suggestion, but when I send the code to the Repetier host I get the Wrong checksum and Unknown command warnings as a return, I think that when we send the code to the machine, we do a check before we do the work we want, how can we disable it?
NeverGiveUp
CC BY-SA 3.0
2017-07-26T14:43:19.100Z
2017-07-26T14:48:38.437Z
2017-07-26T14:48:38.437Z
Matt Clark
<p>I need to send a complex password to my machine. The machine needs to decrypt it and run it. I have not found enough resources for such an operation. </p>

<p>More detailed description:</p>

<p>I am developing a new feature for my 3D printer which runs on Repetier. (It may be on a different firmware that I can do this job).
I want to change my 3D printer so it can understand special encrypted G-codes alongside normal g-codes. Lets describe it with an example:</p>

<p>Normally, 3D printers can read and apply standard g-code files like:</p>

<pre><code>G28
G0 X10 Y20 E30
.
.
.
etc.
</code></pre>

<p>But I am developing a g-code encryption method which encrypts any g-code and turns it into a text like:
 </p>

<pre><code>M999 !4#^
M999 ^s+.&amp;&amp;/..* ….
.
.
etc.
</code></pre>

<p>I want to change the firmware for my printer so it understands if the related g-code is encrypted by checking every line if it stars with M999 (or starts with some other pattern character which I will decide later).</p>

<p>To do is, I need to understand how Repetier works, especially how command debug  works and how I can parse my encrypted code from my encrypted g-code file.</p>

<p>I could not understand how repetier.h / command.cpp works and how it parses the line and redirects to functional cases.</p>

<software><firmware><repetier><repetier-host>
How do I decrypt messages on my Repetier firmware?
NeverGiveUp
# How do I decrypt messages on my Repetier firmware?

(Asked by: username_0 on 2017-07-26)

I need to send a complex password to my machine. The machine needs to decrypt it and run it. I have not found enough resources for such an operation. 
More detailed description:
I am developing a new feature for my 3D printer which runs on Repetier. (It may be on a different firmware that I can do this job).
I want to change my 3D printer so it can understand special encrypted G-codes alongside normal g-codes. Lets describe it with an example:
Normally, 3D printers can read and apply standard g-code files like:
G28
G0 X10 Y20 E30
.
.
.
etc.

But I am developing a g-code encryption method which encrypts any g-code and turns it into a text like:
 
M999 !4#^
M999 ^s+.&&/..* ….
.
.
etc.

I want to change the firmware for my printer so it understands if the related g-code is encrypted by checking every line if it stars with M999 (or starts with some other pattern character which I will decide later).
To do is, I need to understand how Repetier works, especially how command debug  works and how I can parse my encrypted code from my encrypted g-code file.
I could not understand how repetier.h / command.cpp works and how it parses the line and redirects to functional cases.

**Tags:** software, firmware, repetier, repetier-host

---

## 1 answers

### Answer by username_1 on 2017-07-26. Score: 1

Looking through the source I found Commands.cpp that has a loop.
void Commands::commandLoop() {
    while(true) {
        ...
        Commands::executeGCode(code);
    }
}

If we find the executeGCode method, we see that it calls:
processMCode(com);

And finding the processMCode method, we have the switch case you can add your own logic to.
void Commands::processMCode(GCode *com) {
    switch( com->M ) {
        case 3: // Spindle/laser on
            ...

        case 999: // Your custom logic

After decoding your encrypted string, I think it would be best to call back into the first method mentioned, and let the process start from the top with the unencrypted command.
case 999:

    // Custom logic
    executeGCode(unencrypted);
    break;

> **Comments:**
> **username_0**: Thanks for the answer, Sorry for waiting for reply, I tried your suggestion, but when I send the code to the Repetier host I get the Wrong checksum and Unknown command warnings as a return, I think that when we send the code to the machine, we do a check before we do the work we want, how can we disable it?  

---

