Method of storing text data

in #securitylast month

Secure storage of text data is crucial, especially if that data contains personal, financial, or other sensitive information. The topic I want to discuss concerns everything: the storage of banking data, passwords, access keys, the address of a mistress, and so on. Since we all blog here on a blockchain system, it's easy to assume that this also applies to securely storing seed phrases. In my opinion, the text below will eliminate the need to engrave 12 (or 24) seed words on a steel plate.

Storage of text data

AES (Advanced Encryption Standard) is a symmetric encryption algorithm used to protect data. I am self-taught in this field and have been working for many years in web markup and design, PHP programming, and a bit of JavaScript. HTML is not programming but markup. That means HTML codes do not run the website’s execution mechanism but only form its structure and appearance. In JavaScript, third-party libraries are used to work with AES, as encryption functions are not built into the language.

AES encryption involves using the same secret word or key for both encryption and decryption of data. This makes it a symmetric mechanism, unlike asymmetric methods, which use two different keys (a public one for encryption and a private one for decryption).

To implement AES in JavaScript, the user provides the data (message) and the secret key, and the library encrypts the data, returning the encrypted result. In the reverse process, using the same key, the library decrypts the data.

An example of text encryption and decryption using AES and the CryptoJS library:

  1. Connecting the library. First, add a link to the library in your HTML file:
    <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
    
    
  2. Example of encryption and decryption:
    <p><strong>Encrypted message:</strong> <span id="encryptedMessage"></span></p>
    <p><strong>Decrypted message:</strong> <span id="decryptedMessage"></span></p>
    
    <script>
    // Encryption
    var message = "Text to be encrypted";
    var secretKey = "Secret_Key";
    
    var encrypted = CryptoJS.AES.encrypt(message, secretKey).toString();
    
    // display the encrypted message on the page
    document.getElementById('encryptedMessage').textContent = encrypted;
    
    // Decryption
    var decrypted = CryptoJS.AES.decrypt(encrypted, secretKey);
    var originalMessage = decrypted.toString(CryptoJS.enc.Utf8);
    
    // We display the decrypted message on the page
    document.getElementById('decryptedMessage').textContent = originalMessage;
    </script>
    

Encrypted text looks like this:

Encryption AES

This example demonstrates text encryption. You should take key storage security very seriously, as the only way to recover it would be through brute force (password guessing). However, the password doesn’t have to be extremely complex, as long as only you know it. For example, I sometimes use the postal code of the district where I grew up as a password. It’s a six-digit number that changed after the collapse of the USSR, but I remembered it for life (back when there was no email).

Personally, I store the encrypted text online, in cloud storage. And a decryption script example in this article ;-)

Use the information in this article at your own risk.

Sort:  

Good job! I wrote a small example on my blog too, but using node.js you can check it out. I like your example too.

Coin Marketplace

STEEM 0.22
TRX 0.20
JST 0.034
BTC 97415.77
ETH 3291.51
USDT 1.00
SBD 3.07