Pular para o conteúdo principal

Postagem em destaque

BlackTDN :: Implementando Funções de Criptografia com "Nós" e "Trançados"

_Créditos da imagem: Gerada com auxílio do ChatGPT_ # Implementando Funções de Criptografia com "Nós" e "Trançados" A criptografia é um dos campos mais fascinantes da ciência da computação. Recentemente, no projeto experimental [Braided Encryption Message](https://github.com/naldodj/naldodj-braided_encryption_message), explorei como conceitos de "nós" e "trançados" podem ser aplicados na criação de algoritmos de criptografia. Este projeto, embora básico, é uma experiência rica para aprender mais sobre a implementação de funções criptográficas e algumas curiosidades relacionadas ao tema. ## Visão Geral do Projeto O repositório contém duas peças fundamentais: 1. [Arquivo C - `c_braided_encryption_message.c`](https://raw.githubusercontent.com/naldodj/naldodj-braided_encryption_message/refs/heads/main/src/c_braided_encryption_message.c): Implementa funções de criptografia em baixo nível, manipulando diretamente a estrutura dos dados para "...

BlackTDN :: Algoritmo para Embaralhar/Desembaralhar o Resultado da função Embaralha




_Créditos da imagem: Gerada com auxílio do ChatGPT_


---

# **Desembaralhando a função Embaralha**

No universo das customizações para o ERP da TOTVS, frequentemente surge a necessidade de compreender o funcionamento de uma função "proprietária" para poder replicá-la em outros sistemas, como SQL, C#, ou C. Uma das funções mais conhecidas nesse contexto é a Embaralha, que tem despertado o interesse de muitos desenvolvedores que desejam utilizar sua lógica em aplicações fora do ambiente TOTVS.

Neste post, apresentarei o resultado de um algoritmo que simula o processo de "embaralhar e desembaralhar" semelhante ao da função Embaralha (testado com strings de 1 a 36 caracteres).

Vale ressaltar que o algoritmo aqui apresentado tem finalidade exclusivamente didática e não é recomendado para uso no ambiente TOTVS Microsiga Protheus. No Protheus, sempre utilize a função nativa Embaralha. Entretanto, se você deseja implementar a lógica para uso externo ao Protheus, este material pode servir como ponto de partida.

Para implementar e testar esse algoritmo, utilizei a linguagem Harbour, compilada para WebAssembly [harbour_wasm](https://fivetechsoft.github.io/harbour_wasm/)



_Créditos da imagem: BlackTDN_

## **Retorno da Embaralha no Protheus**


```markdown

cCRLF:=chr(13)+chr(10)
    cEmbaraLha:="Embaralha('1',0)=>"+EmbaraLha("1",0)+cCRLF
    cEmbaraLha+="Embaralha('12',0)=>"+EmbaraLha("12",0)+cCRLF
    cEmbaraLha+="Embaralha('123',0)=>"+EmbaraLha("123",0)+cCRLF
    cEmbaraLha+="Embaralha('1234',0)=>"+EmbaraLha("1234",0)+cCRLF
    cEmbaraLha+="Embaralha('12345',0)=>"+EmbaraLha("12345",0)+cCRLF
    cEmbaraLha+="Embaralha('123456',0)=>"+EmbaraLha("123456",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567',0)=>"+EmbaraLha("1234567",0)+cCRLF
    cEmbaraLha+="Embaralha('12345678',0)=>"+EmbaraLha("12345678",0)+cCRLF
    cEmbaraLha+="Embaralha('123456789',0)=>"+EmbaraLha("123456789",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890',0)=>"+EmbaraLha("1234567890",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890A',0)=>"+EmbaraLha("1234567890A",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890AB',0)=>"+EmbaraLha("1234567890AB",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABC',0)=>"+EmbaraLha("1234567890ABC",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCD',0)=>"+EmbaraLha("1234567890ABCD",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDE',0)=>"+EmbaraLha("1234567890ABCDE",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDEF',0)=>"+EmbaraLha("1234567890ABCDEF",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDEFG',0)=>"+EmbaraLha("1234567890ABCDEFG",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDEFGH',0)=>"+EmbaraLha("1234567890ABCDEFGH",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHI',0)=>"+EmbaraLha("1234567890ABCDEFGHI",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJ',0)=>"+EmbaraLha("1234567890ABCDEFGHIJ",0)+cCRLF
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJK',0)=>"+EmbaraLha("1234567890ABCDEFGHIJK",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKL',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKL",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLM',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLM",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMN',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMN",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNO',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNO",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOP',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOP",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQ',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQ",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQR',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQR",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRS',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRS",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRST',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRST",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTU',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRSTU",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUV',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRSTUV",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVW',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRSTUVW",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVWX',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRSTUVWX",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVWXY',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRSTUVWXY",0)+cCRLF    
    cEmbaraLha+="Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',0)=>"+EmbaraLha("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",0)+cCRLF    

    eecView(cEmbaraLha)
    
    Embaralha('1',0)=>1
    Embaralha('12',0)=>12
    Embaralha('123',0)=>231
    Embaralha('1234',0)=>4321
    Embaralha('12345',0)=>32154
    Embaralha('123456',0)=>246135
    Embaralha('1234567',0)=>4613572
    Embaralha('12345678',0)=>75318642
    Embaralha('123456789',0)=>531864297
    Embaralha('1234567890',0)=>3691470258
    Embaralha('1234567890A',0)=>691470258A3
    Embaralha('1234567890AB',0)=>741A852B963
    Embaralha('1234567890ABC',0)=>741A852B963C0
    Embaralha('1234567890ABCD',0)=>48B159C260D37A
    Embaralha('1234567890ABCDE',0)=>8B159C260D37AE4
    Embaralha('1234567890ABCDEF',0)=>C951D062EA73FB84
    Embaralha('1234567890ABCDEFG',0)=>951D062EA73FB84GC
    Embaralha('1234567890ABCDEFGH',0)=>50E16AF27BG38CH49D
    Embaralha('1234567890ABCDEFGHI',0)=>E16AF27BG38CH49DI5
    Embaralha('1234567890ABCDEFGHIJ',0)=>FA61GB72HC83ID94JE05
    Embaralha('1234567890ABCDEFGHIJK',0)=>A61GB72HC83ID94JE05KF
    Embaralha('1234567890ABCDEFGHIJKL',0)=>6BH17CI28DJ39EK40FL5AG
    Embaralha('1234567890ABCDEFGHIJKLM',0)=>BH17CI28DJ39EK40FL5AGM6
    Embaralha('1234567890ABCDEFGHIJKLMN',0)=>IC71JD82KE93LF04MGA5NHB6
    Embaralha('1234567890ABCDEFGHIJKLMNO',0)=>C71JD82KE93LF04MGA5NHB6OI
    Embaralha('1234567890ABCDEFGHIJKLMNOP',0)=>7DK18EL29FM30GN4AHO5BIP6CJ
    Embaralha('1234567890ABCDEFGHIJKLMNOPQ',0)=>DK18EL29FM30GN4AHO5BIP6CJQ7
    Embaralha('1234567890ABCDEFGHIJKLMNOPQR',0)=>LE81MF92NG03OHA4PIB5QJC6RKD7
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRS',0)=>E81MF92NG03OHA4PIB5QJC6RKD7SL
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRST',0)=>8FN19GO20HP3AIQ4BJR5CKS6DLT7EM
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTU',0)=>FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUV',0)=>OG91PH02QIA3RJB4SKC5TLD6UME7VNF8
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVW',0)=>G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVWX',0)=>9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVWXY',0)=>HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9
    Embaralha('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',0)=>RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9
```

---
## **Teste do Algoritmo de Embaralhamento usando o Harbour WASM**

```xBase
procedure Main()

    ? "Shuffled: "
    ? "-------------"
    ? "Shuffle('1',0)=>",Shuffle("1",0),"OK Esperado: 1"
    ? "Shuffle('12',0)=>",Shuffle("12",0),"OK Esperado: 12"
    ? "Shuffle('123',0)=>",Shuffle("123",0),"OK Esperado: 231"
    ? "Shuffle('1234',0)=>",Shuffle("1234",0),"OK Esperado: 4321"
    ? "Shuffle('12345',0)=>",Shuffle("12345",0),"OK Esperado: 32154"
    ? "Shuffle('123456',0)=>",Shuffle("123456",0),"OK Esperado: 246135"
    ? "Shuffle('1234567',0)=>",Shuffle("1234567",0),"OK Esperado: 4613572"
    ? "Shuffle('12345678',0)=>",Shuffle("12345678",0),"OK Esperado: 75318642"
    ? "Shuffle('123456789',0)=>",Shuffle("123456789",0),"OK Esperado: 531864297"
    ? "Shuffle('1234567890',0)=>",Shuffle("1234567890",0),"OK: Esperado: 3691470258"
    
    ? "Shuffle('1234567890A',0)=>",Shuffle("1234567890A",0),"OK Esperado: 691470258A3"
    ? "Shuffle('1234567890AB',0)=>",Shuffle("1234567890AB",0),"OK Esperado: 0741A852B963"
    ? "Shuffle('1234567890ABC',0)=>",Shuffle("1234567890ABC",0),"OK Esperado: 741A852B963C0"
    ? "Shuffle('1234567890ABCD',0)=>",Shuffle("1234567890ABCD",0),"OK Esperado: 48B159C260D37A"
    ? "Shuffle('1234567890ABCDE',0)=>",Shuffle("1234567890ABCDE",0),"OK Esperado: 8B159C260D37AE4"
    ? "Shuffle('1234567890ABCDEF',0)=>",Shuffle("1234567890ABCDEF",0),"OK Esperado: C951D062EA73FB84"
    ? "Shuffle('1234567890ABCDEFG',0)=>",Shuffle("1234567890ABCDEFG",0),"OK Esperado: 951D062EA73FB84GC"
    ? "Shuffle('1234567890ABCDEFGH',0)=>",Shuffle("1234567890ABCDEFGH",0),"OK Esperado: 50E16AF27BG38CH49D"
    ? "Shuffle('1234567890ABCDEFGHI',0)=>",Shuffle("1234567890ABCDEFGHI",0),"OK Esperado: 0E16AF27BG38CH49DI5"
    ? "Shuffle('1234567890ABCDEFGHIJ',0)=>",Shuffle("1234567890ABCDEFGHIJ",0),"OK Esperado: FA61GB72HC83ID94JE05"
    
    ? "Shuffle('1234567890ABCDEFGHIJK',0)=>",Shuffle("1234567890ABCDEFGHIJK",0),"OK Esperado: A61GB72HC83ID94JE05KF"
    ? "Shuffle('1234567890ABCDEFGHIJKL',0)=>",Shuffle("1234567890ABCDEFGHIJKL",0),"OK Esperado: 6BH17CI28DJ39EK40FL5AG"
    ? "Shuffle('1234567890ABCDEFGHIJKLM',0)=>",Shuffle("1234567890ABCDEFGHIJKLM",0),"OK Esperado: BH17CI28DJ39EK40FL5AGM6"
    ? "Shuffle('1234567890ABCDEFGHIJKLMN',0)=>",Shuffle("1234567890ABCDEFGHIJKLMN",0),"OK Esperado: IC71JD82KE93LF04MGA5NHB6"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNO',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNO",0),"OK Esperado: C71JD82KE93LF04MGA5NHB6OI"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOP',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOP",0),"OK Esperado: 7DK18EL29FM30GN4AHO5BIP6CJ"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQ',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQ",0),"OK Esperado: DK18EL29FM30GN4AHO5BIP6CJQ7"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQR',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQR",0),"OK Esperado: LE81MF92NG03OHA4PIB5QJC6RKD7"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRS',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRS",0),"OK Esperado: E81MF92NG03OHA4PIB5QJC6RKD7SL"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRST',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRST",0),"OK Esperado: 8FN19GO20HP3AIQ4BJR5CKS6DLT7EM"
    
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTU',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRSTU",0),"OK Esperado: FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUV',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUV",0),"OK Esperado: OG91PH02QIA3RJB4SKC5TLD6UME7VNF8"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVW',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVW",0),"OK Esperado: G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWX',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWX",0),"OK Esperado: 9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWXY',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWXY",0),"OK Esperado: HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9"
    ? "Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',0)=>",Shuffle("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",0),"OK Esperado: RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9"

return

```
---
## **Retorno do Teste do Algoritmo de Embaralhamento usando o Harbour WASM**
```markdown
Shuffled:
-------------
Shuffle('1',0)=> 1 OK Esperado: 1
Shuffle('12',0)=> 12 OK Esperado: 12
Shuffle('123',0)=> 231 OK Esperado: 231
Shuffle('1234',0)=> 4321 OK Esperado: 4321
Shuffle('12345',0)=> 32154 OK Esperado: 32154
Shuffle('123456',0)=> 246135 OK Esperado: 246135
Shuffle('1234567',0)=> 4613572 OK Esperado: 4613572
Shuffle('12345678',0)=> 75318642 OK Esperado: 75318642
Shuffle('123456789',0)=> 531864297 OK Esperado: 531864297
Shuffle('1234567890',0)=> 3691470258 OK: Esperado: 3691470258
Shuffle('1234567890A',0)=> 691470258A3 OK Esperado: 691470258A3
Shuffle('1234567890AB',0)=> 0741A852B963 OK Esperado: 0741A852B963
Shuffle('1234567890ABC',0)=> 741A852B963C0 OK Esperado: 741A852B963C0
Shuffle('1234567890ABCD',0)=> 48B159C260D37A OK Esperado: 48B159C260D37A
Shuffle('1234567890ABCDE',0)=> 8B159C260D37AE4 OK Esperado: 8B159C260D37AE4
Shuffle('1234567890ABCDEF',0)=> C951D062EA73FB84 OK Esperado: C951D062EA73FB84
Shuffle('1234567890ABCDEFG',0)=> 951D062EA73FB84GC OK Esperado: 951D062EA73FB84GC
Shuffle('1234567890ABCDEFGH',0)=> 50E16AF27BG38CH49D OK Esperado: 50E16AF27BG38CH49D
Shuffle('1234567890ABCDEFGHI',0)=> 0E16AF27BG38CH49DI5 OK Esperado: 0E16AF27BG38CH49DI5
Shuffle('1234567890ABCDEFGHIJ',0)=> FA61GB72HC83ID94JE05 OK Esperado: FA61GB72HC83ID94JE05
Shuffle('1234567890ABCDEFGHIJK',0)=> A61GB72HC83ID94JE05KF OK Esperado: A61GB72HC83ID94JE05KF
Shuffle('1234567890ABCDEFGHIJKL',0)=> 6BH17CI28DJ39EK40FL5AG OK Esperado: 6BH17CI28DJ39EK40FL5AG
Shuffle('1234567890ABCDEFGHIJKLM',0)=> BH17CI28DJ39EK40FL5AGM6 OK Esperado: BH17CI28DJ39EK40FL5AGM6
Shuffle('1234567890ABCDEFGHIJKLMN',0)=> IC71JD82KE93LF04MGA5NHB6 OK Esperado: IC71JD82KE93LF04MGA5NHB6
Shuffle('1234567890ABCDEFGHIJKLMNO',0)=> C71JD82KE93LF04MGA5NHB6OI OK Esperado: C71JD82KE93LF04MGA5NHB6OI
Shuffle('1234567890ABCDEFGHIJKLMNOP',0)=> 7DK18EL29FM30GN4AHO5BIP6CJ OK Esperado: 7DK18EL29FM30GN4AHO5BIP6CJ
Shuffle('1234567890ABCDEFGHIJKLMNOPQ',0)=> DK18EL29FM30GN4AHO5BIP6CJQ7 OK Esperado: DK18EL29FM30GN4AHO5BIP6CJQ7
Shuffle('1234567890ABCDEFGHIJKLMNOPQR',0)=> LE81MF92NG03OHA4PIB5QJC6RKD7 OK Esperado: LE81MF92NG03OHA4PIB5QJC6RKD7
Shuffle('1234567890ABCDEFGHIJKLMNOPQRS',0)=> E81MF92NG03OHA4PIB5QJC6RKD7SL OK Esperado: E81MF92NG03OHA4PIB5QJC6RKD7SL
Shuffle('1234567890ABCDEFGHIJKLMNOPQRST',0)=> 8FN19GO20HP3AIQ4BJR5CKS6DLT7EM OK Esperado: 8FN19GO20HP3AIQ4BJR5CKS6DLT7EM
Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTU',0)=> FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8 OK Esperado: FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8
Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUV',0)=> OG91PH02QIA3RJB4SKC5TLD6UME7VNF8 OK Esperado: OG91PH02QIA3RJB4SKC5TLD6UME7VNF8
Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVW',0)=> G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO OK Esperado: G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO
Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWX',0)=> 9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP OK Esperado: 9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP
Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWXY',0)=> HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9 OK Esperado: HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9
Shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',0)=> RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9 OK Esperado: RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9
```

---
## **Teste do Algoritmo de Desembaralhamento usando o Harbour WASM**

```xBase
procedure Main()

    ? "UnscrambLed: "
    ? "-------------"
    ? "Shuffle('1',1)=>",Shuffle("1",1),"OK Esperado: 1"
    ? "Shuffle('12',1)=>",Shuffle("12",1),"OK Esperado: 12"
    ? "Shuffle('231',1)=>",Shuffle("231",1),"OK Esperado: 123"
    ? "Shuffle('4321',1)=>",Shuffle("4321",1),"OK Esperado: 1234"
    ? "Shuffle('32154',1)=>",Shuffle("32154",1),"OK Esperado: 12345"
    ? "Shuffle('246135',1)=>",Shuffle("246135",1),"OK Esperado: 123456"
    ? "Shuffle('4613572',1)=>",Shuffle("4613572",1),"OK Esperado: 1234567"
    ? "Shuffle('75318642',1)=>",Shuffle("75318642",1),"OK Esperado: 12345678 "
    ? "Shuffle('531864297',1)=>",Shuffle("531864297",1),"OK Esperado: 123456789"
    ? "Shuffle('3691470258',1)=>",Shuffle("3691470258",1),"OK Esperado: 1234567890"
    
    ? "Shuffle('0741A852693',1)=>",Shuffle("691470258A3",1),"OK Esperado: 1234567890A"
    ? "Shuffle('0741A852B963',1)=>",Shuffle("0741A852B963",1),"OK Esperado: 1234567890AB"
    ? "Shuffle('741A852B963C0',1)=>",Shuffle('741A852B963C0',1),"OK Esperado: 1234567890ABC"
    ? "Shuffle('48B159C260D37A',1)=>",Shuffle('48B159C260D37A',1),"OK Esperado: 1234567890ABCD"
    ? "Shuffle('8B159C260D37AE4',1)=>",Shuffle('8B159C260D37AE4',1),"OK Esperado: 1234567890ABCDE"
    ? "Shuffle('C951D062EA73FB84',1)=>",Shuffle('C951D062EA73FB84',1),"OK Esperado: 1234567890ABCDEF"
    ? "Shuffle('951D062EA73FB84GC',1)=>",Shuffle('951D062EA73FB84GC',1),"OK Esperado: 1234567890ABCDEFG"
    ? "Shuffle('50E16AF27BG38CH49D',1)=>",Shuffle('50E16AF27BG38CH49D',1),"OK Esperado: 1234567890ABCDEFGH"
    ? "Shuffle('0E16AF27BG38CH49DI5',1)=>",Shuffle('0E16AF27BG38CH49DI5',1),"OK Esperado: 1234567890ABCDEFGHI"
    ? "Shuffle('FA61GB72HC83ID94JE05',1)=>",Shuffle('FA61GB72HC83ID94JE05',1),"OK Esperado: 1234567890ABCDEFGHIJ"
    
    ? "Shuffle('A61GB72HC83ID94JE05KF',1)=>",Shuffle("A61GB72HC83ID94JE05KF",1),"OK Esperado: 1234567890ABCDEFGHIJK"
    ? "Shuffle('6BH17CI28DJ39EK40FL5AG',1)=>",Shuffle("6BH17CI28DJ39EK40FL5AG",1),"OK Esperado: 1234567890ABCDEFGHIJKL"
    ? "Shuffle('BH17CI28DJ39EK40FL5AGM6',1)=>",Shuffle("BH17CI28DJ39EK40FL5AGM6",1),"OK Esperado: 1234567890ABCDEFGHIJKLM"
    ? "Shuffle('IC71JD82KE93LF04MGA5NHB6',1)=>",Shuffle("IC71JD82KE93LF04MGA5NHB6",1),"OK Esperado: 1234567890ABCDEFGHIJKLMN"    
    ? "Shuffle('C71JD82KE93LF04MGA5NHB6OI',1)=>",Shuffle("C71JD82KE93LF04MGA5NHB6OI",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNO"
    ? "Shuffle('7DK18EL29FM30GN4AHO5BIP6CJ',1)=>",Shuffle("7DK18EL29FM30GN4AHO5BIP6CJ",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOP"
    ? "Shuffle('DK18EL29FM30GN4AHO5BIP6CJQ7',1)=>",Shuffle("DK18EL29FM30GN4AHO5BIP6CJQ7",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQ"
    ? "Shuffle('LE81MF92NG03OHA4PIB5QJC6RKD7',1)=>",Shuffle("LE81MF92NG03OHA4PIB5QJC6RKD7",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQR"
    ? "Shuffle('E81MF92NG03OHA4PIB5QJC6RKD7SL',1)=>",Shuffle("E81MF92NG03OHA4PIB5QJC6RKD7SL",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRS"
    ? "Shuffle('8FN19GO20HP3AIQ4BJR5CKS6DLT7EM',1)=>",Shuffle("8FN19GO20HP3AIQ4BJR5CKS6DLT7EM",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRST"    

    ? "Shuffle('FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8',1)=>",Shuffle("FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTU"
    ? "Shuffle('OG91PH02QIA3RJB4SKC5TLD6UME7VNF8',1)=>",Shuffle("OG91PH02QIA3RJB4SKC5TLD6UME7VNF8",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUV"
    ? "Shuffle('G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO',1)=>",Shuffle("G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVW"
    ? "Shuffle('9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP',1)=>",Shuffle("9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVWX"
    ? "Shuffle('HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9',1)=>",Shuffle("HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXY"
    ? "Shuffle('RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9',1)=>",Shuffle("RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9",1),"OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"  

return

```
---
## **Retorno do Teste do Algoritmo de Desembaralhamento usando o Harbour WASM**
```markdown
UnscrambLed:
-------------
Shuffle('1',1)=> 1 OK Esperado: 1
Shuffle('12',1)=> 12 OK Esperado: 12
Shuffle('231',1)=> 123 OK Esperado: 123
Shuffle('4321',1)=> 1234 OK Esperado: 1234
Shuffle('32154',1)=> 12345 OK Esperado: 12345
Shuffle('246135',1)=> 123456 OK Esperado: 123456
Shuffle('4613572',1)=> 1234567 OK Esperado: 1234567
Shuffle('75318642',1)=> 12345678 OK Esperado: 12345678
Shuffle('531864297',1)=> 123456789 OK Esperado: 123456789
Shuffle('3691470258',1)=> 1234567890 OK Esperado: 1234567890
Shuffle('0741A852693',1)=> 1234567890A OK Esperado: 1234567890A
Shuffle('0741A852B963',1)=> 1234567890AB OK Esperado: 1234567890AB
Shuffle('741A852B963C0',1)=> 1234567890ABC OK Esperado: 1234567890ABC
Shuffle('48B159C260D37A',1)=> 1234567890ABCD OK Esperado: 1234567890ABCD
Shuffle('8B159C260D37AE4',1)=> 1234567890ABCDE OK Esperado: 1234567890ABCDE
Shuffle('C951D062EA73FB84',1)=> 1234567890ABCDEF OK Esperado: 1234567890ABCDEF
Shuffle('951D062EA73FB84GC',1)=> 1234567890ABCDEFG OK Esperado: 1234567890ABCDEFG
Shuffle('50E16AF27BG38CH49D',1)=> 1234567890ABCDEFGH OK Esperado: 1234567890ABCDEFGH
Shuffle('0E16AF27BG38CH49DI5',1)=> 1234567890ABCDEFGHI OK Esperado: 1234567890ABCDEFGHI
Shuffle('FA61GB72HC83ID94JE05',1)=> 1234567890ABCDEFGHIJ OK Esperado: 1234567890ABCDEFGHIJ
Shuffle('A61GB72HC83ID94JE05KF',1)=> 1234567890ABCDEFGHIJK OK Esperado: 1234567890ABCDEFGHIJK
Shuffle('6BH17CI28DJ39EK40FL5AG',1)=> 1234567890ABCDEFGHIJKL OK Esperado: 1234567890ABCDEFGHIJKL
Shuffle('BH17CI28DJ39EK40FL5AGM6',1)=> 1234567890ABCDEFGHIJKLM OK Esperado: 1234567890ABCDEFGHIJKLM
Shuffle('IC71JD82KE93LF04MGA5NHB6',1)=> 1234567890ABCDEFGHIJKLMN OK Esperado: 1234567890ABCDEFGHIJKLMN
Shuffle('C71JD82KE93LF04MGA5NHB6OI',1)=> 1234567890ABCDEFGHIJKLMNO OK Esperado: 1234567890ABCDEFGHIJKLMNO
Shuffle('7DK18EL29FM30GN4AHO5BIP6CJ',1)=> 1234567890ABCDEFGHIJKLMNOP OK Esperado: 1234567890ABCDEFGHIJKLMNOP
Shuffle('DK18EL29FM30GN4AHO5BIP6CJQ7',1)=> 1234567890ABCDEFGHIJKLMNOPQ OK Esperado: 1234567890ABCDEFGHIJKLMNOPQ
Shuffle('LE81MF92NG03OHA4PIB5QJC6RKD7',1)=> 1234567890ABCDEFGHIJKLMNOPQR OK Esperado: 1234567890ABCDEFGHIJKLMNOPQR
Shuffle('E81MF92NG03OHA4PIB5QJC6RKD7SL',1)=> 1234567890ABCDEFGHIJKLMNOPQRS OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRS
Shuffle('8FN19GO20HP3AIQ4BJR5CKS6DLT7EM',1)=> 1234567890ABCDEFGHIJKLMNOPQRST OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRST
Shuffle('FN19GO20HP3AIQ4BJR5CKS6DLT7EMU8',1)=> 1234567890ABCDEFGHIJKLMNOPQRSTU OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTU
Shuffle('OG91PH02QIA3RJB4SKC5TLD6UME7VNF8',1)=> 1234567890ABCDEFGHIJKLMNOPQRSTUV OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUV
Shuffle('G91PH02QIA3RJB4SKC5TLD6UME7VNF8WO',1)=> 1234567890ABCDEFGHIJKLMNOPQRSTUVW OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVW
Shuffle('9HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GP',1)=> 1234567890ABCDEFGHIJKLMNOPQRSTUVWX OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVWX
Shuffle('HQ10IR2AJS3BKT4CLU5DMV6ENW7FOX8GPY9',1)=> 1234567890ABCDEFGHIJKLMNOPQRSTUVWXY OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXY
Shuffle('RI01SJA2TKB3ULC4VMD5WNE6XOF7YPG8ZQH9',1)=> 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ OK Esperado: 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
```

## **O código em Harbour (Portável para outras linguagens)**
[versão completa harbour github](https://github.com/naldodj/naldodj-embaralha/tree/main/src/harbour) :: [versão completa tlpp github](https://github.com/naldodj/naldodj-embaralha/tree/main/src/tlpp)
---

Comentários

Postagens mais visitadas