Skip to content

This is a simple example of how cellular automate can be used to encrypt data.

Notifications You must be signed in to change notification settings

gofmanaa/celluar-automat-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a simple example of how cellular automata can be used to encrypt data. An example uses a one-dimensional cellular automaton.

I had an idea to write some code that uses a cellular automaton algorithm to encrypt data. It turned out that this idea was described by Stefan Wolfram back in 1985. For more detail in the link below:

https://content.wolfram.com/uploads/sites/34/2020/07/cryptography-cellular-automata.pdf

How it works

The code includes several helper functions to assist with these operations:

  • stringToBytes converts a string to a slice of bytes

  • parseBinToHex converts a slice of bytes to a hexadecimal string

  • show prints a slice of bytes as a visual representation (using for 0 and | for 1)

  • f is the custom algorithm that calculates the new slice of bytes. It takes three arguments, y1, y2, and y3, and returns the result of y1 ^ (y2 | y3).

Exsample:

We encrypt the string "Hello" and apply the algorithm of a one-dimensional cellular automaton to the binary representation of the string. And let's see the evolution of the data in the algorithm:

Hello
Binary presentation:
0100100001100101011011000110110001101111
 |  |    ||  | | || ||   || ||   || ||||
 |||||  || ||| | |  | | ||  | | ||  |   
||    |||  |   | |||| | | ||| | | ||||  
| |  ||  |||| || |    | | |   | | |   ||
  |||| |||    |  ||  || | || || | || || 
 ||    |  |  ||||| |||  | |  |  | |  | |
 | |  ||||||||     |  ||| ||||||| |||| |
 | ||||       |   |||||   |       |    |
 | |   |     ||| ||    | |||     |||  ||
 | || |||   ||   | |  || |  |   ||  ||| 
|| |  |  | || | || ||||  ||||| || |||  |
   ||||||| |  | |  |   |||     |  |  |||
| ||       |||| ||||| ||  |   ||||||||  
| | |     ||    |     | |||| ||       ||
  | ||   || |  |||   || |    | |     || 
 || | | ||  ||||  | ||  ||  || ||   || |
 |  | | | |||   ||| | ||| |||  | | ||  |
 |||| | | |  | ||   | |   |  ||| | | |||
 |    | | |||| | | || || |||||   | | |  
|||  || | |    | | |  |  |    | || | || 
|  |||  | ||  || | ||||||||  || |  | |  
||||  ||| | |||  | |       |||  |||| |||
    |||   | |  ||| ||     ||  |||    |  
   ||  | || ||||   | |   || |||  |  ||| 
  || ||| |  |   | || || ||  |  ||||||  |
|||  |   ||||| || |  |  | ||||||     |||
   |||| ||     |  ||||||| |     |   ||  
  ||    | |   |||||       ||   ||| || | 
 || |  || || ||    |     || | ||   |  ||
 |  ||||  |  | |  |||   ||  | | | ||||| 
|||||   |||||| ||||  | || ||| | | |    |
     | ||      |   ||| |  |   | | ||  ||
|   || | |    ||| ||   ||||| || | | ||| 
|| ||  | ||  ||   | | ||     |  | | |   
|  | ||| | ||| | || | | |   ||||| | || |
 ||| |   | |   | |  | | || ||     | |  |
 |   || || || || |||| | |  | |   || ||||
 || ||  |  |  |  |    | |||| || ||  |   
||  | |||||||||||||  || |    |  | ||||  
| ||| |            |||  ||  ||||| |   ||
  |   ||          ||  ||| |||     || || 
0010001100000000001100111011100000110110
Encode result: 230033B836

About

This is a simple example of how cellular automate can be used to encrypt data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages