WebCrypto GOST: Encoding/Decoding data tool

This is a live on-line tool. All buttons execute appropriate javascript algorithms with values from the page. The tool is intended for experimentation with data processing. Feel free to make changes in the javascript algorithms, their settings..

Conversion of data formats

Select source and destination data format.

Source contents

                        
Destination contents

                        
                        
                    
Convert procedure
// Prepare convert parameters
function args(type, next) {
    var format = type.value.split('/');
    format[2] = next;
    return format;
}

// Decode data from source
function decode(format, param, ondata) {
    if (format === 'Binary') { 
        var reader = new FileReader();
        reader.onload = function(e) {
            ondata(e.target.result);
        }
        reader.readAsArrayBuffer(fileSourceSelect.files[0]);
    } else {
        ondata(gostCrypto.coding[format].decode(source.textContent, param));
    }
}

// Encode data to destination
function encode(format, param, data) {
    if (format === 'Binary') { 
        saveAs(new Blob([data], {type: 'application/octet-stream'}), destFileName.value);
    } else {
        dest.textContent = gostCrypto.coding[format].encode(data, param);
    }
}

// Execute procedure
decode.apply(this, args(fromtype, function(data) {
    encode.apply(this, args(totype, data));
}));